ssh eating stdin

November 22, 2013
Today I created a script to atumatically modify the wheigt_factor on multiple LPARs.

Here the script:

#!/bin/ksh
SSHHMC="ssh  hscroot@bxh029"
while read system lpar
do
  DEFAULTPROFILE=`$SSHHMC "source ezh; lpardefaultprofile $lpar"`
  $SSHHMC "source ezh; lpardefaultprofile $lpar"
  echo DEFAULTPROFILE=$DEFAULTPROFILE  for lpar $lpar
  echo $SSHHMC chsyscfg -r prof  -m $system -i "name=$DEFAULTPROFILE,lpar_name=$lpar,uncap_weight=85"
  echo ssh hscroot@bxh029 chhwres -r proc -m $system -o s -p $lpar -a "uncap_weight=85"
  echo " ———————————— "
done < /tmp/running_nondr_lpars.txt

The problem is that the while loop is done, but only the first lpar of the tmp-file is executed. This is because the ssh command is processing all the stdin information.

Solved by adding -n into the ssh command:

#!/bin/ksh
SSHHMC="ssh  -n hscroot@bxh029"
while read system lpar
do
  DEFAULTPROFILE=`$SSHHMC "source ezh; lpardefaultprofile $lpar"`
  $SSHHMC "source ezh; lpardefaultprofile $lpar"
  echo DEFAULTPROFILE=$DEFAULTPROFILE  for lpar $lpar
  echo $SSHHMC chsyscfg -r prof  -m $system -i "name=$DEFAULTPROFILE,lpar_name=$lpar,uncap_weight=85"
  echo ssh hscroot@bxh029 chhwres -r proc -m $system -o s -p $lpar -a "uncap_weight=85"
  echo " ———————————— "
done < /tmp/running_nondr_lpars.txt

2 Comments for this entry

Leave a Reply