<?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: executing a script in remote servers in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505077#M681035</link>
    <description>&lt;!--!*#--&gt;The apostrophes in:&lt;BR /&gt;    'test -f $SCRIPT_LVM_INVENTORY ; echo $?'&lt;BR /&gt;mean that it's looking for a file named:&lt;BR /&gt;    $SCRIPT_LVM_INVENTORY&lt;BR /&gt;not:&lt;BR /&gt;    /home/edsadm/scripts/LVM_Inventory.sh&lt;BR /&gt;.&lt;BR /&gt;&lt;BR /&gt;Try quotation marks:&lt;BR /&gt;    "test -f $SCRIPT_LVM_INVENTORY ; echo $?"&lt;BR /&gt;&lt;BR /&gt;You know, like the other remsh command.</description>
    <pubDate>Tue, 29 Sep 2009 17:07:52 GMT</pubDate>
    <dc:creator>Steven Schweda</dc:creator>
    <dc:date>2009-09-29T17:07:52Z</dc:date>
    <item>
      <title>executing a script in remote servers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505076#M681034</link>
      <description>hi dears,&lt;BR /&gt;i am working on a script tat will provide all the LVM data of a HP UX server, it's called LVM_Inventory.sh, and now i am working on a script that will execute LVM_Inventory.sh in remote servers,&lt;BR /&gt;so first i have to check if the script existe and then execute it, afteer i will add how to download the result file, if it does not exist the script will copy LVM_Inventory.sh in the remote server an then run it&lt;BR /&gt;&lt;BR /&gt;i tried to fix the script all the day and i just don't know how to do it, so here is my script and i will be happy of your feedbacks&lt;BR /&gt;#! /bin/ksh&lt;BR /&gt;&lt;BR /&gt;############################################&lt;BR /&gt;&lt;BR /&gt;###   this script needs a list of servers names&lt;BR /&gt;### each line is a server name&lt;BR /&gt;############################################&lt;BR /&gt;&lt;BR /&gt;liste=$1&lt;BR /&gt;&lt;BR /&gt;DIR_SCRIPT_LVM_INVENTORY="/home/edsadm/scripts/"&lt;BR /&gt;NAME_SCRIPT_LVM_INVENTORY="LVM_Inventory.sh"&lt;BR /&gt;SCRIPT_LVM_INVENTORY="$DIR_SCRIPT_LVM_INVENTORY$NAME_SCRIPT_LVM_INVENTORY"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;for nomServeur in $(cat "$liste")&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;#RET=`remsh $nomServeur -l root 'test -f $SCRIPT_LVM_INVENTORY ; echo $?'`&lt;BR /&gt;&lt;BR /&gt;if [ $RET -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;        echo "then $nomServeur"&lt;BR /&gt;        remsh $nomServeur $SCRIPT_LVM_INVENTORY $nomServeur&lt;BR /&gt;else&lt;BR /&gt;        echo "else $nomServeur"&lt;BR /&gt;        # on copie le fichier sur le serveur&lt;BR /&gt;        host=`hostname`&lt;BR /&gt;        remsh  "$nomServeur" -l root "mkdir -p /home/edsadm/scripts 2&amp;gt;/dev/null"&lt;BR /&gt;        rcp -p "root@$host:$SCRIPT_LVM_INVENTORY" "root@$nomServeur:$SCRIPT_LVM_INVENTORY"&lt;BR /&gt;        remsh $nomServeur $SCRIPT_LVM_INVENTORY $nomServeur&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;the test of existance of the file does not give the true value, it gives the non existence of the file even if i just copy it my self.</description>
      <pubDate>Tue, 29 Sep 2009 16:25:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505076#M681034</guid>
      <dc:creator>istartedin2009</dc:creator>
      <dc:date>2009-09-29T16:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: executing a script in remote servers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505077#M681035</link>
      <description>&lt;!--!*#--&gt;The apostrophes in:&lt;BR /&gt;    'test -f $SCRIPT_LVM_INVENTORY ; echo $?'&lt;BR /&gt;mean that it's looking for a file named:&lt;BR /&gt;    $SCRIPT_LVM_INVENTORY&lt;BR /&gt;not:&lt;BR /&gt;    /home/edsadm/scripts/LVM_Inventory.sh&lt;BR /&gt;.&lt;BR /&gt;&lt;BR /&gt;Try quotation marks:&lt;BR /&gt;    "test -f $SCRIPT_LVM_INVENTORY ; echo $?"&lt;BR /&gt;&lt;BR /&gt;You know, like the other remsh command.</description>
      <pubDate>Tue, 29 Sep 2009 17:07:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505077#M681035</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-09-29T17:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: executing a script in remote servers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505078#M681036</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;First, I assume that you didn't mean to comment out the establishment of the 'RET' variable with:&lt;BR /&gt;&lt;BR /&gt;#RET=`remsh $nomServeur -l root 'test -f $SCRIPT_LVM_INVENTORY ; echo $?'`&lt;BR /&gt;&lt;BR /&gt;Then, instead of :&lt;BR /&gt;&lt;BR /&gt;RET=`remsh $nomServeur -l root 'test -f $SCRIPT_LVM_INVENTORY ; echo $?'`&lt;BR /&gt;&lt;BR /&gt;I would do:&lt;BR /&gt;&lt;BR /&gt;RET=$(ssh $nonServeur -n -l root [ -f ${FILE} ] &amp;amp;&amp;amp; echo 0)&lt;BR /&gt;&lt;BR /&gt;Notice that I didn't quote the command argument allowing the shell to interpret the metacharacters on the _local_ host first.&lt;BR /&gt;&lt;BR /&gt;Lastly, notice that I have used 'ssh' instead of the less-secure 'remsh'.  The syntax is virtually identical and I find it more reliable.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 29 Sep 2009 17:10:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505078#M681036</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-09-29T17:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: executing a script in remote servers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505079#M681037</link>
      <description>&amp;gt;for nomServeur in $(cat "$liste")&lt;BR /&gt;&lt;BR /&gt;If you are going to use $(), you should also remove cat.  And probably no need to use "" around $liste, unless you have spaces:&lt;BR /&gt;for nomServeur in $(&amp;lt; $liste); do</description>
      <pubDate>Tue, 29 Sep 2009 20:56:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505079#M681037</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-09-29T20:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: executing a script in remote servers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505080#M681038</link>
      <description>hi dears,&lt;BR /&gt;let me thank all of you for your answers.&lt;BR /&gt;&lt;BR /&gt;Steven, i try you proposition but it doesn't work with double quotes "" also,&lt;BR /&gt;James R. i can't use ssh so i used remsh without -n (as you said that's the same), but it did not work.&lt;BR /&gt;Dennis thank you for you help also.&lt;BR /&gt;&lt;BR /&gt;so before making the boucle and so on, i write another script to find the solution of the probleme and then i will write it in my first script, here is the new script with the results.&lt;BR /&gt;i test in two servers, frls does not have the script on it so i must have 1 in the return of the test, and frlg which has the script and must have 0 in the return of the test.&lt;BR /&gt;&lt;BR /&gt;#! /bin/ksh&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DIR_SCRIPT_LVM_INVENTORY="/home/edsadm/scripts/"&lt;BR /&gt;NAME_SCRIPT_LVM_INVENTORY="LVM_Inventory.sh"&lt;BR /&gt;SCRIPT_LVM_INVENTORY="$DIR_SCRIPT_LVM_INVENTORY$NAME_SCRIPT_LVM_INVENTORY"&lt;BR /&gt;&lt;BR /&gt;r=$(remsh frls -l root 'test -f /home/edsadm/scripts/LVM_Inventory.sh ; echo $?')&lt;BR /&gt;s=$(remsh frlg -l root 'test -f /home/edsadm/scripts/LVM_Inventory.sh ; echo $?')&lt;BR /&gt;&lt;BR /&gt;RET=1&lt;BR /&gt;RET=$(remsh frls -l root [ -f ${SCRIPT_LVM_INVENTORY} ] &amp;amp;&amp;amp; echo 0)&lt;BR /&gt;ET=$(remsh frlg -l root [ -f ${SCRIPT_LVM_INVENTORY} ] &amp;amp;&amp;amp; echo 0)&lt;BR /&gt;&lt;BR /&gt;rp=$(remsh frls -l root "test -f $SCRIPT_LVM_INVENTORY ; echo $?")&lt;BR /&gt;sp=$(remsh frlg -l root "test -f $SCRIPT_LVM_INVENTORY ; echo $?")&lt;BR /&gt;&lt;BR /&gt;echo "Forum example"&lt;BR /&gt;echo "$RET $ET"&lt;BR /&gt;&lt;BR /&gt;echo "correct"&lt;BR /&gt;echo "$r $s"&lt;BR /&gt;&lt;BR /&gt;echo "with parameter"&lt;BR /&gt;echo "$rp $sp"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and here is the result&lt;BR /&gt;frd7:/root/home/root (root) ./LVM_Payasage_Inventory.sh&lt;BR /&gt;Forum example&lt;BR /&gt;0 0&lt;BR /&gt;correct&lt;BR /&gt;1 0&lt;BR /&gt;with parameter&lt;BR /&gt;0 0&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Sep 2009 09:41:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505080#M681038</guid>
      <dc:creator>istartedin2009</dc:creator>
      <dc:date>2009-09-30T09:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: executing a script in remote servers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505081#M681039</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;&amp;gt; James R. i can't use ssh so i used remsh without -n (as you said that's the same), but it did not work. &lt;BR /&gt;&lt;BR /&gt;The '-n' works for 'ssh' or 'remsh'.  It is generally wise to include it:  see the manpages for an explanation.&lt;BR /&gt;&lt;BR /&gt;For the snippet of code I suggested, 'remsh' does not consistently work while 'ssh' does.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 30 Sep 2009 12:52:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505081#M681039</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-09-30T12:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: executing a script in remote servers</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505082#M681040</link>
      <description>&lt;!--!*#--&gt;&amp;gt; Steven, i try you proposition but it&lt;BR /&gt;&amp;gt; doesn't work with double quotes "" also, &lt;BR /&gt;&lt;BR /&gt;Some of it does.  You want&lt;BR /&gt;      $file_name&lt;BR /&gt;inside quotation marks, because you want&lt;BR /&gt;_this_ variable evaluated on the _local_&lt;BR /&gt;host, where the variable is defined, but you&lt;BR /&gt;need to have&lt;BR /&gt;      $?&lt;BR /&gt;inside apostrophes, because you don't want&lt;BR /&gt;_it_ evaluated here, you want _it_ evaluated&lt;BR /&gt;on the _remote_ host, where it gets the&lt;BR /&gt;status value from the remote "test" command.&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;dy # echo $file_yes&lt;BR /&gt;/root/.profile&lt;BR /&gt;&lt;BR /&gt;dy # echo $file_no&lt;BR /&gt;/root/.profileXX&lt;BR /&gt;&lt;BR /&gt;dy # remsh dy -l root "test -f $file_yes ; "'echo  $?'&lt;BR /&gt;0&lt;BR /&gt;dy # remsh dy -l root "test -f $file_no ; "'echo  $?'&lt;BR /&gt;1&lt;BR /&gt;&lt;BR /&gt;And if your file name includes problem&lt;BR /&gt;characters, then you need to work a little&lt;BR /&gt;harder:&lt;BR /&gt;&lt;BR /&gt;dy # echo $file_odd&lt;BR /&gt;a b c&lt;BR /&gt;&lt;BR /&gt;dy # ls -l 'a b c'&lt;BR /&gt;-rw-r--r--   1 root       sys              5 Sep 30 10:42 a b c&lt;BR /&gt;&lt;BR /&gt;dy # remsh dy -l root 'test -f "'"$file_yes"'" ; echo  $?'&lt;BR /&gt;0&lt;BR /&gt;&lt;BR /&gt;dy # remsh dy -l root 'test -f "'"$file_no"'" ; echo  $?'&lt;BR /&gt;1&lt;BR /&gt;&lt;BR /&gt;dy # remsh dy -l root 'test -f "'"$file_odd"'" ; echo  $?'&lt;BR /&gt;0&lt;BR /&gt;&lt;BR /&gt;You need to think about which shell where&lt;BR /&gt;sees which quotation marks.&lt;BR /&gt;&lt;BR /&gt;Everything's complicated.</description>
      <pubDate>Wed, 30 Sep 2009 14:52:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/executing-a-script-in-remote-servers/m-p/4505082#M681040</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2009-09-30T14:52:53Z</dc:date>
    </item>
  </channel>
</rss>

