lilgreen has asked for the wisdom of the Perl Monks concerning the following question:
I have a hash (%check) with the following content:
'DESCRIPTION' => 'Checks that various system filesystems are at the mi +nimum size' 'NAME' => 'filesys_sizes' 'TIP' => '(/<filesystem> is less than XGB, increase FS size to minimum +) The /tmp filesystems has a minimum filesystem size of 1GB Increase the filesystem to a minimum of 1GB chfs -a size=2097152 /tmp' 'TIP_NUMBER' => 37 'CHECK_CODE' => ‘#!/usr/bin/ksh93 typeset -A SIZE_MIN SIZE_MIN=([/var]=2097152 [/tmp]=1048576 [/home]=1048576) ISHACMP=$(lslpp -Lqc cluster.*.server.rte 2>/dev/null | grep -c cluste +r) for fs in ${!SIZE_MIN[*]}; do fssize=$(df -k $fs | grep -v Filesystem | awk \'{print $2}\') if (( $fssize < ${SIZE_MIN[$fs]} )); then print "BAD;$fs is less than minimum size ($SIZE_MIN[$fs]}), in +crease to minimum size" elif (( $fssize == ${SIZE_MIN[$fs]} )); then print "GOOD;$fs is at minimum size (${SIZE_MIN[$fs]} kb)" else print "GOOD;$fs is greater ($fssize) than minimum (${SIZE_MIN[ +$fs]})" fi done'
Here's the subroutine that's actually running the CHECK_CODE element:
sub exec_check { my (%check) = @_; my @return = `$check{'CHECK_CODE'}`; foreach (@return) { my ($status, $string) = split(";", $_); print "$status $string"; } }
I want to execute $data{'CHECK_CODE'} as a "chunk" - whatever is in it is run as a whole, and the perl script just handles the data returned from the chunk. I've tried and backticks and qx// and IPC::Run, and even open() but they all seem to have the same limitation - when I pass the hash element as the command to be executed it gets interpreted one line at a time. I always get the same error:
sh[3]: typeset: 0403-010 A specified flag is not valid for this comman +d.
On the system this being run on (AIX) this is a valid error for ksh because it doesn't have a -A option for typeset, but ksh93 does support -A so it's clear that each line of the code is being interpreted as a new child process. I've been fiddling with it for a while and am currently at the banging-my-head-against-the-wall phase, because I'm sure there's something completely obvious that I'm missing. It seems like it should be straight forward.
|
|---|