in reply to AIX harddisk sum of storage

Your script contains at least one typo in the ssh invocation. Where exactly are you having problems?

my $space = $SSH root\@$one for i in lspv | awk '{print \$1}'; do boo +tinfo -s \$i; done | awk '{sum+=\$1}END{print (sum\/1024)}'}'"`; # ^ here a backquote is missing print "$space\n";

My suggestion would be to first print out the command locally to see whether it looks like you intend to, or whether a dollar sign or backslash gets interpolated away.

I would move the summation to Perl instead of keeping it in awk, but that's more a stylistic issue.

Replies are listed 'Best First'.
Re^2: AIX harddisk sum of storage
by pjzero@90 (Novice) on Jul 23, 2018 at 17:32 UTC

    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

      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.