<?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: ftp script with file date and time selection in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/ftp-script-with-file-date-and-time-selection/m-p/3963154#M95146</link>
    <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;get a listing of the available remote files and loop of this list to sort out the local available:&lt;BR /&gt;&lt;BR /&gt;cd localdir&lt;BR /&gt;# setup your ftp connection&lt;BR /&gt;ftpini='_init_commands_&lt;BR /&gt;cd remote'&lt;BR /&gt;&lt;BR /&gt;ftp remote &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;$ftpini&lt;BR /&gt;ls . remote.lst&lt;BR /&gt;bye&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;while read entry&lt;BR /&gt;do&lt;BR /&gt;  [ -z "$entry" ] &amp;amp;&amp;amp; continue&lt;BR /&gt;  [ -f $entry ] &amp;amp;&amp;amp; continue&lt;BR /&gt;  print get $entry&lt;BR /&gt;done &lt;REMOTE.LST&gt;getme.lst&lt;BR /&gt;&lt;BR /&gt;if [ -s getme.lst ]&lt;BR /&gt;then&lt;BR /&gt;    ftp remote&amp;lt;&lt;EOF&gt;&lt;/EOF&gt;$ftpini&lt;BR /&gt;bin&lt;BR /&gt;$(&lt;GETME.LST&gt;&lt;/GETME.LST&gt;bye&lt;BR /&gt;EOF&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;You'll have to test this ...&lt;BR /&gt;&lt;BR /&gt;mfG Peter&lt;/REMOTE.LST&gt;</description>
    <pubDate>Sun, 18 Mar 2007 04:57:03 GMT</pubDate>
    <dc:creator>Peter Nikitka</dc:creator>
    <dc:date>2007-03-18T04:57:03Z</dc:date>
    <item>
      <title>ftp script with file date and time selection</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ftp-script-with-file-date-and-time-selection/m-p/3963149#M95141</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;We have a file generated by the cron job every 5 minutes past of certain hour during one day time period everyday.&lt;BR /&gt;&lt;BR /&gt;And now we need to ftp those files after they has been generated by the cron job, at the same time we do not want to ftp those files that we have already ftp(ed) before, so we need only to ftp the latest file generated.&lt;BR /&gt;&lt;BR /&gt;The format of the file is as followed :&lt;BR /&gt;&lt;BR /&gt;HOSTNAME_YYMMDDHHMM.gz&lt;BR /&gt;&lt;BR /&gt;So in the directory we have the folowing bunch of files&lt;BR /&gt;&lt;BR /&gt;NHU2CG1_0703140905.gz&lt;BR /&gt;NHU2CG1_0703141205.gz&lt;BR /&gt;NHU2CG1_0703141605.gz&lt;BR /&gt;NHU2CG1_0703141905.gz&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;&lt;BR /&gt;Can someone advise how to write the ftp script to transfer those file according the the requirement mentioned above ?&lt;BR /&gt;&lt;BR /&gt;Many thanks</description>
      <pubDate>Fri, 16 Mar 2007 02:05:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ftp-script-with-file-date-and-time-selection/m-p/3963149#M95141</guid>
      <dc:creator>Kasman_1</dc:creator>
      <dc:date>2007-03-16T02:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: ftp script with file date and time selection</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ftp-script-with-file-date-and-time-selection/m-p/3963150#M95142</link>
      <description>You need to do several things.&lt;BR /&gt;&lt;BR /&gt;1)  First you have to ftp one file.  Have you found how to do that?&lt;BR /&gt;&lt;BR /&gt;2) The second thing you need to do is to select which files to do.  The simplest way to do that is to use touch -r to set a reference file.  The first time you want to either set it to the last file you did manually, or to some arbitrary time last year.&lt;BR /&gt;&lt;BR /&gt;Then you can use: find NHU2CG1_*.gz -newer reference-file.&lt;BR /&gt;&lt;BR /&gt;You would want to send all those files to the script/fragment you created for 1) above.&lt;BR /&gt;&lt;BR /&gt;3) In the above process, you need to sort those files so you can set the reference file to the last one you copied.&lt;BR /&gt;&lt;BR /&gt;Now you are all set to do this later.</description>
      <pubDate>Fri, 16 Mar 2007 02:41:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ftp-script-with-file-date-and-time-selection/m-p/3963150#M95142</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-03-16T02:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: ftp script with file date and time selection</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ftp-script-with-file-date-and-time-selection/m-p/3963151#M95143</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Please pardon for my ignorant as I have never written any shell script before.&lt;BR /&gt;&lt;BR /&gt;So would appreciate if someone can give some sample script that has been written before and I will try to modify according to my environment.&lt;BR /&gt;&lt;BR /&gt;Thanks !</description>
      <pubDate>Fri, 16 Mar 2007 03:14:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ftp-script-with-file-date-and-time-selection/m-p/3963151#M95143</guid>
      <dc:creator>Kasman_1</dc:creator>
      <dc:date>2007-03-16T03:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: ftp script with file date and time selection</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ftp-script-with-file-date-and-time-selection/m-p/3963152#M95144</link>
      <description>Hi,&lt;BR /&gt;unless you insist on using ftp, why don't you use things like rdist and rsync?&lt;BR /&gt;&lt;BR /&gt;Otherwise, please see:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=991609" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=991609&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Please also read:&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/helptips.do?#33" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/helptips.do?#33&lt;/A&gt; on how to reward any useful answers given to your questions.&lt;BR /&gt;&lt;BR /&gt;Your profile shows you only awarded points to 1 of 15 answers !</description>
      <pubDate>Fri, 16 Mar 2007 03:49:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ftp-script-with-file-date-and-time-selection/m-p/3963152#M95144</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2007-03-16T03:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: ftp script with file date and time selection</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ftp-script-with-file-date-and-time-selection/m-p/3963153#M95145</link>
      <description>&lt;!-- !*# --&gt;&lt;P&gt;&amp;gt;So would appreciate if someone can give some sample script that has been written before and I will try to modify according to my environment.&lt;BR /&gt;&lt;BR /&gt;See Peter's link on how to do ftp. Here is one way to do the selection:&lt;BR /&gt;&lt;BR /&gt;# Create reference file, with date of Jan 1, 1970, if not there&lt;BR /&gt;if [ ! -f NHU2CG1_.ref ]; then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; touch 0101000070 NHU2CG1_.ref&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;find NHU2CG1_??????????.gz -newer NHU2CG1_.ref | sort |&lt;BR /&gt;while read file; do&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo ftp_one_file $file # ftp this one&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; touch -r $file NHU2CG1_.ref&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I'm assuming the names of the files are created based on the times, and the above ascii sort matches the time sort of ll -t.&lt;BR /&gt;&lt;BR /&gt;The "echo ftp_one_file" place is where you would put your script to ftp one file.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2011 03:40:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ftp-script-with-file-date-and-time-selection/m-p/3963153#M95145</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-10-10T03:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: ftp script with file date and time selection</title>
      <link>https://community.hpe.com/t5/operating-system-linux/ftp-script-with-file-date-and-time-selection/m-p/3963154#M95146</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;get a listing of the available remote files and loop of this list to sort out the local available:&lt;BR /&gt;&lt;BR /&gt;cd localdir&lt;BR /&gt;# setup your ftp connection&lt;BR /&gt;ftpini='_init_commands_&lt;BR /&gt;cd remote'&lt;BR /&gt;&lt;BR /&gt;ftp remote &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;$ftpini&lt;BR /&gt;ls . remote.lst&lt;BR /&gt;bye&lt;BR /&gt;EOF&lt;BR /&gt;&lt;BR /&gt;while read entry&lt;BR /&gt;do&lt;BR /&gt;  [ -z "$entry" ] &amp;amp;&amp;amp; continue&lt;BR /&gt;  [ -f $entry ] &amp;amp;&amp;amp; continue&lt;BR /&gt;  print get $entry&lt;BR /&gt;done &lt;REMOTE.LST&gt;getme.lst&lt;BR /&gt;&lt;BR /&gt;if [ -s getme.lst ]&lt;BR /&gt;then&lt;BR /&gt;    ftp remote&amp;lt;&lt;EOF&gt;&lt;/EOF&gt;$ftpini&lt;BR /&gt;bin&lt;BR /&gt;$(&lt;GETME.LST&gt;&lt;/GETME.LST&gt;bye&lt;BR /&gt;EOF&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;You'll have to test this ...&lt;BR /&gt;&lt;BR /&gt;mfG Peter&lt;/REMOTE.LST&gt;</description>
      <pubDate>Sun, 18 Mar 2007 04:57:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/ftp-script-with-file-date-and-time-selection/m-p/3963154#M95146</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-03-18T04:57:03Z</dc:date>
    </item>
  </channel>
</rss>

