<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: while read line only reads the first line when passing to a script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374203#M639664</link>
    <description>&lt;P&gt;Seems the issue is with zlogin itself....sigh....&lt;/P&gt;</description>
    <pubDate>Thu, 27 Oct 2011 15:43:20 GMT</pubDate>
    <dc:creator>Heretic</dc:creator>
    <dc:date>2011-10-27T15:43:20Z</dc:date>
    <item>
      <title>while read line only reads the first line when passing to a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374069#M639663</link>
      <description>&lt;P&gt;First off - this is weird - going to take sometime getting used to these forums...I'm having ITRC withdrawal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Okay, so I have a file...currrently has 9 lines (could have more could have less).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each line has 7 variables that I want to pass to a script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, in come while read line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;while read line
do
./exe.backup.ksh $line
done &amp;lt;list&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;That only processes the first line&amp;nbsp; :(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Echo works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;while read line
do
echo $line
echo " "
done &amp;lt;list


z_vbwaqa22 QB4 qb4adm /usr/sap/QB4/D06/exe /usr/sap/QB4/D06/exe.new /sapmnt/QB4/exe /sapmnt/QB4/exe.new

z_vbwjqa22 QB7 qb7adm /usr/sap/QB7/J09/exe /usr/sap/QB7/J09/exe.new /sapmnt/QB7/exe /sapmnt/QB7/exe.new

z_vcuaqa21 QU3 qu3adm /usr/sap/QU3/DVEBMGS36/exe /usr/sap/QU3/DVEBMGS36/exe.new /sapmnt/QU3/exe /sapmnt/QU3/exe.new

z_vecaqa22 QR3 qr3adm /usr/sap/QR3/D01/exe /usr/sap/QR3/D01/exe.new /sapmnt/QR3/exe /sapmnt/QR3/exe.new

z_vecjqa22 QR7 qr7adm /usr/sap/QR7/J04/exe /usr/sap/QR7/J04/exe.new /sapmnt/QR7/exe /sapmnt/QR7/exe.new

z_vepjqa21 QP6 qp6adm /usr/sap/QP6/JC63/exe /usr/sap/QP6/JC63/exe.new /sapmnt/QP6/exe /sapmnt/QP6/exe.new

z_vgrjqa22 QG6 qg6adm /usr/sap/QG6/J84/exe /usr/sap/QG6/J84/exe.new /sapmnt/QG6/exe /sapmnt/QG6/exe.new

z_vpiaqa22 QX3 qx3adm /usr/sap/QX3/D31/exe /usr/sap/QX3/D31/exe.new /sapmnt/QX3/exe /sapmnt/QX3/exe.new

z_vsraqa22 QY3 qy3adm /usr/sap/QY3/D11/exe /usr/sap/QY3/D11/exe.new /sapmnt/QY3/exe /sapmnt/QY3/exe.new&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Here's the script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#!/bin/ksh
# backup the exe dirs
# gwild 10262011
#
#
# Do you want to pass a file to this script?
# Put the 3 variables on a single line in a file named for example "list":
# z_vbwaqa21 qb4adm QB4 /usr/sap/QB4/DVEBMGS06/exe      /sapmnt/QB4/exe /usr/sap/QB4/DVEBMGS06/exe.new  /sapmnt/QB4/exe.new
#
# Then run the script like so:
#
#    while read line
#    do
#    ./exe.backup.ksh $line
#    done &amp;lt;list
#
# variables
LOG=/tmp/exe.backup.log
# check for parameters else give usage
if [ $# -lt 1 -o \( $# -gt 7 -a $# -lt 7 \) ]
then
  echo "Usage:"
  echo "exe.backup.ksh \"zone\" \"SID\" \"sidadm\" \"SRC1\" \"TRG1\" \"SRC2\" \"TRG2\""
  echo "Example:"
  echo "exe.backup.ksh z_vbwaqa21 QB4 qb4adm /usr/sap/QB4/DVEBMGS06/exe /usr/sap/QB4/DVEBMGS06/exe.new /sapmnt/QB4/exe  /sapmnt/QB4/exe.new"
  echo " "
  echo "Note: results in $LOG"
  exit 1
fi
echo " "

ZON=$1
SID=$2
ADM=$3
SRC1=$4
TRG1=$5
SRC2=$6
TRG2=$7

date &amp;gt;&amp;gt; $LOG
zlogin $ZON "su - $ADM -c 'echo "$SID" ; uname -n ; mkdir $TRG1 ; cd $SRC1 ; tar cf - * | ( cd $TRG1; tar xfp -) ; echo "how many files in $SRC1 ?" ; find $SRC1 |wc -l ; echo "How many files in $TRG1 ?" ; find $TRG1 |wc -l'" &amp;gt;&amp;gt;$LOG
date &amp;gt;&amp;gt; $LOG
zlogin $ZON "su - $ADM -c 'echo "$SID" ; uname -n ; mkdir $TRG2 ; cd $SRC2 ; tar cf - * | ( cd $TRG2; tar xfp -) ; echo "how many files in $SRC2 ?" ; find $SRC2 |wc -l ; echo "How many files in $TRG2 ?" ; find $TRG2 |wc -l'" &amp;gt;&amp;gt;$LOG
date &amp;gt;&amp;gt; $LOG&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, what am I doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2011 13:59:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374069#M639663</guid>
      <dc:creator>Heretic</dc:creator>
      <dc:date>2011-10-27T13:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: while read line only reads the first line when passing to a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374203#M639664</link>
      <description>&lt;P&gt;Seems the issue is with zlogin itself....sigh....&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2011 15:43:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374203#M639664</guid>
      <dc:creator>Heretic</dc:creator>
      <dc:date>2011-10-27T15:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: while read line only reads the first line when passing to a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374219#M639665</link>
      <description>&lt;P&gt;hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why this line?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;if [ $# -lt 1 -o \( $# -gt 7 -a $# -lt 7 \) ]&lt;/PRE&gt;&lt;P&gt;If you want to verify that you have seven arguments, do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;if [ $# -ne 7 ]&lt;/PRE&gt;&lt;P&gt;But then your comments note: "# Do you want to pass a file to this script? # Put the 3 variables on a single line in a file named for example "list":"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...JRF...&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2011 15:51:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374219#M639665</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-10-27T15:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: while read line only reads the first line when passing to a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374343#M639666</link>
      <description>&lt;P&gt;work around:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#!/bin/ksh
# backup the exe dirs
# gwild 10262011
#
#
# Do you want to pass a file to this script?
######################################################################################################################
# TOO BAD - zlogin always breaks out of a while loop so you will have to run this script manually for every zone.
######################################################################################################################
# UPDATE - found a workaround by just creating a tmp file with the zlogin command - yet you can NOT just cut and paste
# it into your session - you have to sh it: sh /tmp/exe.backup.tmp
######################################################################################################################
# Put the 7 variables on a single line in a file named for example "list":
# z_vbwaqa21 qb4adm QB4 /usr/sap/QB4/DVEBMGS06/exe      /sapmnt/QB4/exe /usr/sap/QB4/DVEBMGS06/exe.new  /sapmnt/QB4/exe.new
#
# Then run the script like so:
#
#    while read line
#    do
#    ./exe.backup.ksh ${line}
#    done &amp;lt;list
#
# variables

LOG=/tmp/exe.backup.log
SHFILE=/tmp/exe.backup.tmp

# check for parameters else give usage
if [ $# -ne 7 ]
then
  echo "Usage:"
  echo "exe.backup.ksh \"zone\" \"SID\" \"sidadm\" \"SRC1\" \"TRG1\" \"SRC2\" \"TRG2\""
  echo "Example:"
  echo "exe.backup.ksh z_vbwaqa21 QB4 qb4adm /usr/sap/QB4/DVEBMGS06/exe /usr/sap/QB4/DVEBMGS06/exe.new /sapmnt/QB4/exe  /sap
mnt/QB4/exe.new"
  echo " "
  echo "Note: results in $LOG"
  exit 1
fi

ZON=$1
SID=$2
ADM=$3
SRC1=$4
TRG1=$5
SRC2=$6
TRG2=$7

date &amp;gt;&amp;gt; $LOG
echo "zlogin $ZON \"su - $ADM -c 'echo $SID ; uname -n ; mkdir $TRG1 ; cd $SRC1 ; tar cf - * | ( cd $TRG1; tar xfp -) ; echo
 "how many files in $SRC1 ?" ; find $SRC1 |wc -l ; echo "How many files in $TRG1 ?" ; find $TRG1 |wc -l'\"" &amp;gt;&amp;gt;$SHFILE
echo "zlogin $ZON \"su - $ADM -c 'echo $SID ; uname -n ; mkdir $TRG2 ; cd $SRC2 ; tar cf - * | ( cd $TRG2; tar xfp -) ; echo
 "how many files in $SRC2 ?" ; find $SRC2 |wc -l ; echo "How many files in $TRG2 ?" ; find $TRG2 |wc -l'\"" &amp;gt;&amp;gt;$SHFILE&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2011 18:36:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374343#M639666</guid>
      <dc:creator>Heretic</dc:creator>
      <dc:date>2011-10-27T18:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: while read line only reads the first line when passing to a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374365#M639667</link>
      <description>&lt;P&gt;Hi (again):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt; # TOO BAD - zlogin always breaks out of a while loop so you will have to run this script manually for every zone.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This isn't HP-UX.&amp;nbsp; Rather is appears to be Sun-OS.&amp;nbsp; I'd suggest a non-HP community or at least an agnostic UNIX/Linux one in the future :-)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...JRF...&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2011 19:08:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374365#M639667</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-10-27T19:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: while read line only reads the first line when passing to a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374375#M639668</link>
      <description>&lt;P&gt;Unfortunately, Solaris admins tend to keep to themselves - in other words, I would never get any help from one of them.&amp;nbsp; ;)&lt;/P&gt;</description>
      <pubDate>Thu, 27 Oct 2011 19:31:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374375#M639668</guid>
      <dc:creator>Heretic</dc:creator>
      <dc:date>2011-10-27T19:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: while read line only reads the first line when passing to a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374647#M639669</link>
      <description>&lt;P&gt;&amp;gt;Each line has 7 variables that I want to pass to a script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have 7 variables, you should really read 7 values:&amp;nbsp; (Use more descriptive names)&lt;/P&gt;&lt;P&gt;while read v1 v2 v3 v4 v5 v6 v7; do&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ./exe.backup.ksh $v1 $v2 $v3 $v4 $v5 $v6 $v7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;echo works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not really.&amp;nbsp; You don't know if there are one parm or 7.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Oct 2011 03:07:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/while-read-line-only-reads-the-first-line-when-passing-to-a/m-p/5374647#M639669</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-10-28T03:07:27Z</dc:date>
    </item>
  </channel>
</rss>

