0

I have been trying to collect the LPAR id details in by executing a remote command from AIX server (Korn Shell) to IBM HMC (restricted Bash Shell) over SSH.

Im having trouble in substituting the lpar names with spaces over SSH.

Below is the total servers in the frame. Could you please help me with the solution on substituting the variable LPAR on SSH for HMC

vio1001
vio1002
lpar4556 PROD DBX02

Script Tried:

oldIFS=$IFS
IFS=$'\n'
set -o noglob
for lpar in $(ssh -nq hscroot@ibmhmc101 "lssyscfg -r lpar -m frame220-aix-p750 -F name,lpar_env" | cut -d, -f 1 | sort)
do
   echo "$lpar"
   for state in $(ssh -nq hscroot@ibmhmc101 "oldIFS=$IFS; IFS=$'\n';set -o noglob;lssyscfg -m frame220-aix-p750 -r lpar -F name:state --filter lpar_names="${lpar}" << "EOF"
EOF" | cut -d: -f2)
   do
      echo $state
   done
done

Error: 
vio1001
vio1002
lpar4556 PROD DBX02
/bin/bash: line 1: vio1001: command not found
/bin/bash: line 2: vio1002: command not found

Ru

i
g
  • There is a problem in substituting the variable with lpar names in spaces ( lpar4556 PROD DBX02) – satsensort Oct 29 at 10:05
  • what do you intend with << "EOF" in inner for ? – Archemar Oct 29 at 10:17
  • 1) what is the output of lssyscfg -m frame220-aix-p750 -r lpar -F name:state --filter lpar_names=vio1001 ? – Archemar Oct 29 at 10:30
  • Last I knew, the HMC shell had a shell that could nest for loops; any reason you don't loop inside the HMC shell? – Jeff Schaller Oct 29 at 10:44
  • Hi @JeffSchaller i would like to collect the LPAR details and frame and related LPAR id details for all servers on different HMC's.. – satsensort Oct 29 at 11:18
0

you need to protect lpar so i will add \ before each double-quote

This is a example , that test both :

for lpar in "1"  "2 3" "2;3" "abc" "abc def" "abc;def"   ; 
do 
     echo "#${lpar}#" ;
     ssh XXXX@EXAMPLE.COM  "printf 'arg1:%s arg2:%s\n'  --filter  par_names=\"${lpar}\"  " ;
     ssh XXXX@EXAMPLE.COM  "printf 'arg1:%s arg2:%s\n'  --filter  par_names="${lpar}"  " ;
done 
  • Still getting same error. Looks like it is not picking the LPAR name with spaces. – satsensort Nov 6 at 8:52
0

Tried the below workaround using while read line. This fixed my issue.

ssh hscroot@$hmc "lssyscfg -r lpar -m $frame -F name,lpar_env" | cut -d, -f1 | sort | while read line
do
lpar=`echo ${line} | cut -d= -f2`
echo "$lpar"
for lpar_id in $(ssh -nq hscroot@$hmc "lssyscfg -r lpar -m $frame -F name:lpar_env:lpar_id --filter lpar_names="${lpar}" " | cut -d: -f3 | sort)
do
echo "$lpar_id"
done
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.