<?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: Help ksh script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418724#M663571</link>
    <description>solution is good, maybe you can add file check to make more robust script steps, for example:&lt;BR /&gt;&lt;BR /&gt;#2)check using md5sum OFA and TFA&lt;BR /&gt;   #This is a waste of time&lt;BR /&gt;&lt;BR /&gt; if [ -f "$TFA" ] ; then&lt;BR /&gt;&lt;BR /&gt;   diff $OFA $TFA &amp;gt; /dev/null&lt;BR /&gt;   if [ $? -eq 0 ]; then&lt;BR /&gt;      rm -f $TFA.gz&lt;BR /&gt;      gzip $TFA&lt;BR /&gt;      MD5=$(md5sum $TFA.gz | awk '{print $1}')&lt;BR /&gt;      break&lt;BR /&gt;   fi&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;done</description>
    <pubDate>Wed, 13 May 2009 08:00:17 GMT</pubDate>
    <dc:creator>Hakki Aydin Ucar</dc:creator>
    <dc:date>2009-05-13T08:00:17Z</dc:date>
    <item>
      <title>Help ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418721#M663568</link>
      <description>Dear All,&lt;BR /&gt;&lt;BR /&gt;Terms:&lt;BR /&gt;OFA = Original File on Server A&lt;BR /&gt;TFA = Target File on Server A&lt;BR /&gt;TFB = Target FIle on Server B&lt;BR /&gt;I want to create script that do the following steps:&lt;BR /&gt;1)copy file on server A from OFA to TFA&lt;BR /&gt;2)check using md5sum OFA and TFA&lt;BR /&gt;  if (md5sum OFA = md5sum TFA) then&lt;BR /&gt;  gzip TFA&lt;BR /&gt;  md5sum TFA.gz&lt;BR /&gt;  else go to step 1)&lt;BR /&gt;3)rcp -p serverA:TFA.gz  serverB:TFB.gz&lt;BR /&gt;  md5sum TFB.gz&lt;BR /&gt;  if (md5sum TFA.gz = md5sum TFB.gz) then&lt;BR /&gt;  remsh B gunzip TFB.gz&lt;BR /&gt;  remsh B chmod 444 TFB&lt;BR /&gt;  else go to 3)&lt;BR /&gt;&lt;BR /&gt;Please help.&lt;BR /&gt;Many thanks.&lt;BR /&gt;</description>
      <pubDate>Wed, 13 May 2009 02:20:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418721#M663568</guid>
      <dc:creator>zap_2</dc:creator>
      <dc:date>2009-05-13T02:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418722#M663569</link>
      <description>&lt;!--!*#--&gt;Something like this.  Note it is a waste of time to use md5sum to compare two local files, when you could use diff.&lt;BR /&gt;&lt;BR /&gt;#1)copy file on server A from OFA to TFA&lt;BR /&gt;&lt;BR /&gt;while : ; do&lt;BR /&gt;   cp -f $OFA $TFA&lt;BR /&gt;&lt;BR /&gt;   #2)check using md5sum OFA and TFA&lt;BR /&gt;   #This is a waste of time&lt;BR /&gt;   diff $OFA $TFA &amp;gt; /dev/null&lt;BR /&gt;   if [ $? -eq 0 ]; then&lt;BR /&gt;      rm -f $TFA.gz&lt;BR /&gt;      gzip $TFA&lt;BR /&gt;      MD5=$(md5sum $TFA.gz | awk '{print $1}')&lt;BR /&gt;      break&lt;BR /&gt;   fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;#3)rcp -p serverA:TFA.gz serverB:TFB.gz&lt;BR /&gt;while : ; do&lt;BR /&gt;   remsh $serverB -n rm -f $TFB.gz&lt;BR /&gt;   rcp -p $TFA.gz $serverB:$TFB.gz&lt;BR /&gt;&lt;BR /&gt;   MD5B=$(remsh $serverB -n md5sum $TFB.gz | awk '{print $1}')&lt;BR /&gt;#    if (md5sum TFA.gz = md5sum TFB.gz) then&lt;BR /&gt;   if [ "$MD5" = "$MD5B" ]; then&lt;BR /&gt;      remsh $serverB -n rm -f $TFB&lt;BR /&gt;      remsh $serverB -n gunzip $TFB.gz&lt;BR /&gt;      remsh $serverB -n chmod 444 $TFB&lt;BR /&gt;      break&lt;BR /&gt;   fi&lt;BR /&gt;done</description>
      <pubDate>Wed, 13 May 2009 05:21:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418722#M663569</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-05-13T05:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418723#M663570</link>
      <description>Dear Dennis,&lt;BR /&gt;&lt;BR /&gt;Many thanks for your help.&lt;BR /&gt;&lt;BR /&gt;Dear All,&lt;BR /&gt;&lt;BR /&gt;Any another suggested script?&lt;BR /&gt;Many thanks in advanced.</description>
      <pubDate>Wed, 13 May 2009 07:10:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418723#M663570</guid>
      <dc:creator>zap_2</dc:creator>
      <dc:date>2009-05-13T07:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418724#M663571</link>
      <description>solution is good, maybe you can add file check to make more robust script steps, for example:&lt;BR /&gt;&lt;BR /&gt;#2)check using md5sum OFA and TFA&lt;BR /&gt;   #This is a waste of time&lt;BR /&gt;&lt;BR /&gt; if [ -f "$TFA" ] ; then&lt;BR /&gt;&lt;BR /&gt;   diff $OFA $TFA &amp;gt; /dev/null&lt;BR /&gt;   if [ $? -eq 0 ]; then&lt;BR /&gt;      rm -f $TFA.gz&lt;BR /&gt;      gzip $TFA&lt;BR /&gt;      MD5=$(md5sum $TFA.gz | awk '{print $1}')&lt;BR /&gt;      break&lt;BR /&gt;   fi&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;done</description>
      <pubDate>Wed, 13 May 2009 08:00:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418724#M663571</guid>
      <dc:creator>Hakki Aydin Ucar</dc:creator>
      <dc:date>2009-05-13T08:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Help ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418725#M663572</link>
      <description>Dear Hakki thanks for your help.&lt;BR /&gt;&lt;BR /&gt;Dear All please more suggested scripts.&lt;BR /&gt;Many thanks in advanced.</description>
      <pubDate>Wed, 13 May 2009 08:14:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418725#M663572</guid>
      <dc:creator>zap_2</dc:creator>
      <dc:date>2009-05-13T08:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Help ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418726#M663573</link>
      <description>Hey;&lt;BR /&gt;&lt;BR /&gt;The reason he wants to do the md5sum is to verify the remote copy was completed successfully.  Copying the file locally, then rcp'ing it doesn't satisfy that concern.&lt;BR /&gt;&lt;BR /&gt;I *much* prefer ssh/scp to remsh and rcp.  All the convenience plus security.  You effectively have your script from your description.  The requirements were quite specific and easily translated into ksh:&lt;BR /&gt;&lt;BR /&gt;lm=1&lt;BR /&gt;om=2&lt;BR /&gt;&lt;BR /&gt;while [ "${lm}" != "${om}" ]&lt;BR /&gt;do&lt;BR /&gt;scp -q $OFA ${target_host}:${TFA}&lt;BR /&gt;lm=$(md5sum $OFA}&lt;BR /&gt;om=$(ssh ${target_host} md5sum ${TFA})&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;## Note: if you *actually* want to copy from the second server to a third server, you will need to use ssh/scp.  remsh/rcp doesn't support that concept. &lt;BR /&gt;&lt;BR /&gt;## The only reason I can see to do that is if the local host and the 2nd remote host don't have direct connectivity.  Otherwise, it's simpler just to reiterate the loop above using the 2nd host as target_host.&lt;BR /&gt;&lt;BR /&gt;scp -q ${target_host}:$TFA ${remote_host}:$TFB&lt;BR /&gt;lm=1; om=2&lt;BR /&gt;while [ "${lm}" != "${om}" ]&lt;BR /&gt;do&lt;BR /&gt;lm=$(ssh ${target_host} md5sum ${TFA})&lt;BR /&gt;om=$(ssh ${remote_host} md5sum ${TFB})&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;HTH;&lt;BR /&gt;&lt;BR /&gt;Doug</description>
      <pubDate>Wed, 13 May 2009 12:22:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418726#M663573</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2009-05-13T12:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: Help ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418727#M663574</link>
      <description>One improvement you can do is only do the while loops a fixed number of times:&lt;BR /&gt;(( limit = 5 ))&lt;BR /&gt;while (( (limit -= 1) &amp;gt;= 0 )); do</description>
      <pubDate>Thu, 14 May 2009 01:18:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418727#M663574</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-05-14T01:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Help ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418728#M663575</link>
      <description>Dear All,&lt;BR /&gt;&lt;BR /&gt;More improvements in script are welcome.&lt;BR /&gt;Many thanks in advanced.</description>
      <pubDate>Thu, 14 May 2009 05:48:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418728#M663575</guid>
      <dc:creator>zap_2</dc:creator>
      <dc:date>2009-05-14T05:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Help ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418729#M663576</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;BTW, Dennis:&lt;BR /&gt;To check two local files for equalness, I prefer&lt;BR /&gt;if cmp -s file1 file2&lt;BR /&gt;then print equal files&lt;BR /&gt;else print file differ&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;The 'cmp' stops at the first difference - a 'diff' runs through the files completely.&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Thu, 14 May 2009 10:16:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418729#M663576</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2009-05-14T10:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: Help ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418730#M663577</link>
      <description>You could just simply gzip the file on Server A, that way you can save some bandwith at step 1. ;)</description>
      <pubDate>Thu, 14 May 2009 12:00:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418730#M663577</guid>
      <dc:creator>Viktor Balogh</dc:creator>
      <dc:date>2009-05-14T12:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help ksh script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418731#M663578</link>
      <description>oh sorry, just noticed that OFA and TFA means the same server</description>
      <pubDate>Thu, 14 May 2009 12:03:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-ksh-script/m-p/4418731#M663578</guid>
      <dc:creator>Viktor Balogh</dc:creator>
      <dc:date>2009-05-14T12:03:25Z</dc:date>
    </item>
  </channel>
</rss>

