<?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: Shell script help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329609#M873802</link>
    <description>Better so:&lt;BR /&gt;Start again:&lt;BR /&gt;You wanted 1 file - the latest...&lt;BR /&gt;&lt;BR /&gt;ll -lt | grep GSIT | head -n 1&lt;BR /&gt;&lt;BR /&gt;There you are&lt;BR /&gt;&lt;BR /&gt;All the best&lt;BR /&gt;Victor</description>
    <pubDate>Tue, 13 Jul 2004 03:30:43 GMT</pubDate>
    <dc:creator>Victor BERRIDGE</dc:creator>
    <dc:date>2004-07-13T03:30:43Z</dc:date>
    <item>
      <title>Shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329604#M873797</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I've been tasked with creating a unix shell script that will select the latest created file and ftp it to another i.e. the file is currently generated every 12 hours (at 00:00 &amp;amp; 12:00) and 7 days worth are kept at any one time. Therefore the files in the directory are as follows:&lt;BR /&gt;&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul  5 00:03 GSIT20040705000002.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul  5 12:03 GSIT20040705120004.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul  6 00:03 GSIT20040706000002.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul  6 12:03 GSIT20040706120004.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul  7 00:03 GSIT20040707000003.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul  7 12:03 GSIT20040707120005.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul  8 00:03 GSIT20040708000003.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul  8 12:03 GSIT20040708120005.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul  9 00:03 GSIT20040709000003.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul  9 12:03 GSIT20040709120002.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul 10 00:03 GSIT20040710000002.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul 10 12:03 GSIT20040710120005.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul 11 00:03 GSIT20040711000002.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul 11 12:03 GSIT20040711120005.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul 12 00:03 GSIT20040712000002.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul 12 12:03 GSIT20040712120005.drf&lt;BR /&gt;-rw-rw-rw-   1 nortel   nortel     12423 Jul 13 00:03 GSIT20040713000003.drf&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Therefore what I need to do is at midnight after the file has been created I will need to select the latest file and ftp it to another server and at mid-day again I will have to perform the same task but with the latest file generated at midday etc, etc. As can be seen above the files are generated automatically and contain the date &amp;amp; time in the filename.&lt;BR /&gt;&lt;BR /&gt;I'm a beginner at shell scripting and would greatly appreciate any help that can be provided.&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;AK</description>
      <pubDate>Tue, 13 Jul 2004 03:04:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329604#M873797</guid>
      <dc:creator>Andy Koumi_1</dc:creator>
      <dc:date>2004-07-13T03:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329605#M873798</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Use the system commands to find the newest file such as&lt;BR /&gt;&lt;BR /&gt;dir=/home/steves/tmp&lt;BR /&gt;ls -1tr $dir|tail -n 1|while read line&lt;BR /&gt;do&lt;BR /&gt;file=$(find $dir -name $line)&lt;BR /&gt;echo $file&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Put your dir where mine is and file is the newest one&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.shelldorado.com/" target="_blank"&gt;http://www.shelldorado.com/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Is a good place for a learner&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;             Steve Steel</description>
      <pubDate>Tue, 13 Jul 2004 03:23:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329605#M873798</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2004-07-13T03:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329606#M873799</link>
      <description>Hi,&lt;BR /&gt;Since I dont know how you want your ftp, all I can do here is how to select your file:&lt;BR /&gt;ll -ltÂ¦grep GSIT Â¦ head -n 1&lt;BR /&gt;&lt;BR /&gt;Good luck&lt;BR /&gt;Vi</description>
      <pubDate>Tue, 13 Jul 2004 03:24:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329606#M873799</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2004-07-13T03:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329607#M873800</link>
      <description>Hi Andy,&lt;BR /&gt;&lt;BR /&gt;you could find out the latest file by using "tail -1" command&lt;BR /&gt;&lt;BR /&gt;For example :&lt;BR /&gt;&lt;BR /&gt;for i in `ls /&lt;DIR&gt;|tail -1`&lt;BR /&gt;do&lt;BR /&gt;ftp $i ...&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;Franky&lt;/DIR&gt;</description>
      <pubDate>Tue, 13 Jul 2004 03:26:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329607#M873800</guid>
      <dc:creator>Franky_1</dc:creator>
      <dc:date>2004-07-13T03:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329608#M873801</link>
      <description>Sorry for the strange char, dont know where they come from...&lt;BR /&gt;You should read "pipe" I will give a try with another char | and se if it displays correctly&lt;BR /&gt;&lt;BR /&gt;All the best&lt;BR /&gt;Victor</description>
      <pubDate>Tue, 13 Jul 2004 03:27:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329608#M873801</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2004-07-13T03:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329609#M873802</link>
      <description>Better so:&lt;BR /&gt;Start again:&lt;BR /&gt;You wanted 1 file - the latest...&lt;BR /&gt;&lt;BR /&gt;ll -lt | grep GSIT | head -n 1&lt;BR /&gt;&lt;BR /&gt;There you are&lt;BR /&gt;&lt;BR /&gt;All the best&lt;BR /&gt;Victor</description>
      <pubDate>Tue, 13 Jul 2004 03:30:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329609#M873802</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2004-07-13T03:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329610#M873803</link>
      <description>Check this &lt;BR /&gt;&lt;BR /&gt;for i in `ls -t`&lt;BR /&gt;do&lt;BR /&gt;echo $i&lt;BR /&gt;# Other commands...&lt;BR /&gt;exit&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;sks</description>
      <pubDate>Tue, 13 Jul 2004 03:39:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329610#M873803</guid>
      <dc:creator>Sanjay Kumar Suri</dc:creator>
      <dc:date>2004-07-13T03:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329611#M873804</link>
      <description>Thanks guys!!&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;Andy</description>
      <pubDate>Tue, 13 Jul 2004 03:41:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329611#M873804</guid>
      <dc:creator>Andy Koumi_1</dc:creator>
      <dc:date>2004-07-13T03:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329612#M873805</link>
      <description>Hi AK,&lt;BR /&gt;&lt;BR /&gt;YOu can schedule the script to run twice a day through cron job. i.e&lt;BR /&gt;&lt;BR /&gt;00 00,12 * * * /path/script_name &amp;gt; output_log&lt;BR /&gt;&lt;BR /&gt;and the script_name can contain the following line.&lt;BR /&gt;Initiall touch a temp_file. Then find the GSIT file that was newer than the touched file as.&lt;BR /&gt;&lt;BR /&gt;find /path -name *GSIT* -newer touched_temp_file |cpio...........&lt;BR /&gt;and after the copy to thebother server&lt;BR /&gt;remove the touch_temp_file&lt;BR /&gt;touch temp_file again.&lt;BR /&gt;&lt;BR /&gt;So that next time the GSIT* file generated will be newer than the touched file. And you have this files generated only twice a day at 00:00 and 12:00. So when the cron job copies the file and touched the temp file, next GSIT file will be newer than the touched file.&lt;BR /&gt;&lt;BR /&gt;I hope this helps You.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Indira A&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Jul 2004 03:49:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329612#M873805</guid>
      <dc:creator>Indira Aramandla</dc:creator>
      <dc:date>2004-07-13T03:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329613#M873806</link>
      <description>Hi,&lt;BR /&gt;Just to participate,&lt;BR /&gt;Similar to Victor but this one will only return the Filename:&lt;BR /&gt;&lt;BR /&gt;# ls -t | head -n 1&lt;BR /&gt;&lt;BR /&gt;You can even assign the name to an variable and write a script to FTP the file using that varible.&lt;BR /&gt;&lt;BR /&gt;# var1=`ls -t | head -n 1`&lt;BR /&gt;(remember these are back quotes)&lt;BR /&gt;&lt;BR /&gt;Hope that helps.&lt;BR /&gt;Regards,</description>
      <pubDate>Tue, 13 Jul 2004 04:10:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329613#M873806</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2004-07-13T04:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329614#M873807</link>
      <description>hai,&lt;BR /&gt;&lt;BR /&gt; Get the recent created file with a line script as,&lt;BR /&gt;&lt;BR /&gt; #script.ksh&lt;BR /&gt; # usage: &lt;FTPUSERNAME&gt; &lt;PASSWD&gt; &lt;SERVER-NAME&gt;&lt;STORE location=""&gt;&lt;BR /&gt; filename=$(ls -l | grep -v '^total*' | sort -r | head -1)&lt;BR /&gt; &lt;BR /&gt; username=$1&lt;BR /&gt; passwd=$2&lt;BR /&gt; location=$3&lt;BR /&gt;  &lt;BR /&gt; ftp -i -n $server &amp;lt;&amp;lt;-EOF 2&amp;gt;/dev/null&lt;BR /&gt;   user $usename $passwd&lt;BR /&gt;   put $filename $location&lt;BR /&gt;   bye&lt;BR /&gt; EOF&lt;BR /&gt;&lt;BR /&gt; # total message will come if we use ll or ls -l&lt;BR /&gt; &lt;BR /&gt; You can use rcp too instead of ftp for this. make "+" entry in $HOME/.rhosts file on two server&lt;BR /&gt;&lt;BR /&gt; Simulate this in a cron job at your required time (at 00:00 &amp;amp; 12:00)&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Muthukumar.&lt;BR /&gt;Muthukumar.&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;/STORE&gt;&lt;/SERVER-NAME&gt;&lt;/PASSWD&gt;&lt;/FTPUSERNAME&gt;</description>
      <pubDate>Tue, 13 Jul 2004 04:28:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/3329614#M873807</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-07-13T04:28:08Z</dc:date>
    </item>
  </channel>
</rss>

