in reply to Re: AIX harddisk sum of storage
in thread AIX harddisk sum of storage

this is what I see when I run the script, does not like the "do"

sh: -c: line 0: syntax error near unexpected token `do' sh: -c: line 0: `SSH root@server19 for i in lspv | awk '{print $1}';do + bootinfo -s $i;done' 256 sh: -c: line 0: syntax error near unexpected token `do' sh: -c: line 0: `SSH root@server20 for i in lspv | awk '{print $1}';do + bootinfo -s $i;done' 256 sh: -c: line 0: syntax error near unexpected token `do' sh: -c: line 0: `SSH root@server21 for i in lspv | awk '{print $1}';do + bootinfo -s $i;done' 256 sh: -c: line 0: syntax error near unexpected token `do' sh: -c: line 0: `SSH root@server22 for i in lspv | awk '{print $1}';do + bootinfo -s $i;done'

Yet when I run it on an AIX server, things work just fine

root@server01:/] # for i in `/usr/sbin/lspv | awk '{print $1}'`; do bo +otinfo -s $i; done | awk '{sum+=$1}END{print (sum/1024)}' 589.73

Replies are listed 'Best First'.
Re^3: AIX harddisk sum of storage
by Corion (Patriarch) on Jul 23, 2018 at 17:56 UTC

    Your working command includes backticks while your Perl string does not contain them.

    If you want to send backticks to the remote side, you will need to include them in the string, and hope that you get all the shell quoting correct. Personally, I prefer to use $() shell-syntax instead of backticks as that makes the quoting much easier. Instead of backticks in Perl, I will use qx(). That gives me

    my $command = qq[$SSH root\@$one for i in \$(lspv | awk '{print \$1}') +; do bootinfo -s \$i; done | awk '{sum+=\$1}END{print (sum\/1024)}']; warn "[[$command]]"; my $space = qx($command)

    I don't know if I've translated your shell code properly, as to me the original seems to contain a lone double quote and some spurious single quotes.