<?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: ssh within a script not working for some reason in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ssh-within-a-script-not-working-for-some-reason/m-p/5218961#M679055</link>
    <description>That did it Bill....thanks!!!</description>
    <pubDate>Wed, 13 Jan 2010 14:27:07 GMT</pubDate>
    <dc:creator>dev44</dc:creator>
    <dc:date>2010-01-13T14:27:07Z</dc:date>
    <item>
      <title>ssh within a script not working for some reason</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ssh-within-a-script-not-working-for-some-reason/m-p/5218957#M679051</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;The point of the following script is to go out to all our servers and if the /var/mail/root file is current (today's date); then tail the last 100 lines to a file.  Then send me the file.  Now out of the whole list, there are about 8 servers that have a current mail log.  However, my script is only outputting the first entry.  If I just "echo $a" it will echo all servers with a current date....but when I ssh $a and tail the mail log it stops after the first one.  &lt;BR /&gt;&lt;BR /&gt;#! /usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;m=`date +%b`&lt;BR /&gt;d=`date +%e`&lt;BR /&gt;HOME=/home/me/scripts&lt;BR /&gt;LIST=$HOME/serverlists/all.servers&lt;BR /&gt;OUT=/home/me/tmp/mail.out&lt;BR /&gt;OUT2=/home/me/tmp/maildat.out&lt;BR /&gt;MAIL=/var/mail/root&lt;BR /&gt;MAILLIST=me@example.com&lt;BR /&gt;&lt;BR /&gt;if [ -f $OUT ]; then rm $OUT; fi&lt;BR /&gt;if [ -f $OUT2 ]; then rm $OUT2; fi&lt;BR /&gt;&lt;BR /&gt;for x in `cat $LIST`; do&lt;BR /&gt;echo "$x \t `ssh $x ls -la $MAIL |awk '{print $6, $7}'`" &amp;gt;&amp;gt;$OUT2&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;cat $OUT2| while read a b c&lt;BR /&gt;do&lt;BR /&gt;if [ $b = $m ] &amp;amp;&amp;amp; [ $c -eq $d ]; then&lt;BR /&gt;        echo "_________________________________________________________________________\n" &amp;gt;&amp;gt;$OUT&lt;BR /&gt;        echo "\n $a \n" &amp;gt;&amp;gt;$OUT&lt;BR /&gt;        echo "_________________________________________________________________________\n" &amp;gt;&amp;gt;$OUT&lt;BR /&gt;        ssh $a "tail -100 $MAIL" &amp;gt;&amp;gt;$OUT&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;cat $OUT |mailx -s "MAIL Log" $MAILLIST&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Jan 2010 13:47:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ssh-within-a-script-not-working-for-some-reason/m-p/5218957#M679051</guid>
      <dc:creator>dev44</dc:creator>
      <dc:date>2010-01-13T13:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: ssh within a script not working for some reason</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ssh-within-a-script-not-working-for-some-reason/m-p/5218958#M679052</link>
      <description>Use the -n option for all your scripted ssh commands (ssh -n host "some command"). This option redirects stdin for ssh which is only used for interactive sessions.</description>
      <pubDate>Wed, 13 Jan 2010 14:08:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ssh-within-a-script-not-working-for-some-reason/m-p/5218958#M679052</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2010-01-13T14:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: ssh within a script not working for some reason</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ssh-within-a-script-not-working-for-some-reason/m-p/5218959#M679053</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;In addition to adding the '-n' to your 'ssh' as Bill noted, change:&lt;BR /&gt;&lt;BR /&gt;for x in `cat $LIST`; do&lt;BR /&gt;echo "$x \t `ssh $x ls -la $MAIL |awk '{print $6, $7}'`" &amp;gt;&amp;gt;$OUT2&lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;...to:&lt;BR /&gt;&lt;BR /&gt;while read x&lt;BR /&gt;do&lt;BR /&gt;    echo "$x \t $(ssh -n $x ls -la $MAIL|awk '{print $6, $7}')"&lt;BR /&gt;done &amp;lt; ${LIST} &amp;gt; ${OUT2}&lt;BR /&gt;&lt;BR /&gt;This eliminates the extra 'cat' process letting the shell do the read of the input file.  The code also uses the Posix '$()' notation instead of the backticks to run a command.  This is much more readable.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Jan 2010 14:17:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ssh-within-a-script-not-working-for-some-reason/m-p/5218959#M679053</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-01-13T14:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: ssh within a script not working for some reason</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ssh-within-a-script-not-working-for-some-reason/m-p/5218960#M679054</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;debug:&lt;BR /&gt;&lt;BR /&gt;ssh -vvv&lt;BR /&gt;&lt;BR /&gt;redirect the output to a file so you can see the error message.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Wed, 13 Jan 2010 14:20:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ssh-within-a-script-not-working-for-some-reason/m-p/5218960#M679054</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2010-01-13T14:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: ssh within a script not working for some reason</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ssh-within-a-script-not-working-for-some-reason/m-p/5218961#M679055</link>
      <description>That did it Bill....thanks!!!</description>
      <pubDate>Wed, 13 Jan 2010 14:27:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ssh-within-a-script-not-working-for-some-reason/m-p/5218961#M679055</guid>
      <dc:creator>dev44</dc:creator>
      <dc:date>2010-01-13T14:27:07Z</dc:date>
    </item>
  </channel>
</rss>

