<?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: Getting files via sftp in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083339#M92877</link>
    <description>Assuming you have keys working from host1 to host2, you could try something like this to determine the most recent file on host2 from host1:&lt;BR /&gt;&lt;BR /&gt;FILES=`ssh host2 find /directory/with/files/ -type f -mtime -1 -name "CMO_LANG_STD_\*"`&lt;BR /&gt;&lt;BR /&gt;cd /local/dir/to/put/file&lt;BR /&gt;for i in $FILES ; do &lt;BR /&gt;  sftp USER@host2:$i .&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;An easier solution would be to sftp the file from host2 to host1.  Then you only need 1 sftp command.  You could use the find command to determine the most recent file.</description>
    <pubDate>Wed, 12 Dec 2007 21:13:36 GMT</pubDate>
    <dc:creator>Autocross.US</dc:creator>
    <dc:date>2007-12-12T21:13:36Z</dc:date>
    <item>
      <title>Getting files via sftp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083335#M92873</link>
      <description>Hi,&lt;BR /&gt;I have a remote server which publishes flat files everyday.I want to write a shell script which sftp's to the remote server and gets the "latest file". I was thinking how to write the script which first logs on to the server,changes to the directory where the files are and then gets them to the local directory. I am not an expert in sftp,any thoughts on this.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Gyan</description>
      <pubDate>Fri, 07 Dec 2007 15:10:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083335#M92873</guid>
      <dc:creator>Gyankr</dc:creator>
      <dc:date>2007-12-07T15:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Getting files via sftp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083336#M92874</link>
      <description>If I were doing this, I would use Perl's Net::SFTP module. The module takes less than 1 minute to install and has all the primitives that you need. Moreover, it is trivially easy to check the status of each operation so that error checking goes from being a tedious exercise to a very simple operation.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://search.cpan.org/~dbrobins/Net-SFTP-0.10/lib/Net/SFTP.pm" target="_blank"&gt;http://search.cpan.org/~dbrobins/Net-SFTP-0.10/lib/Net/SFTP.pm&lt;/A&gt;</description>
      <pubDate>Fri, 07 Dec 2007 15:48:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083336#M92874</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-12-07T15:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: Getting files via sftp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083337#M92875</link>
      <description>If you setup ssh key exchange on both hosts you wouldn't need to script the login part.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You could get the file like this (on local host):&lt;BR /&gt;cd /local/dir/to/put/file&lt;BR /&gt;sftp USER@host2:/path/to/remote/file  .&lt;BR /&gt;&lt;BR /&gt;The challenge is to determine which file is the latest file.  Can you provide details on this file?  Is it time stamped or does it overwrite an existing file?</description>
      <pubDate>Fri, 07 Dec 2007 16:07:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083337#M92875</guid>
      <dc:creator>Autocross.US</dc:creator>
      <dc:date>2007-12-07T16:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: Getting files via sftp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083338#M92876</link>
      <description>the filenames have the time stamp in it like CMO_LANG_STD_2007-11-23.dat and yes we are using public/private keys.I thought of sftp -b option but i cannot write shell scripts in the batch file :(</description>
      <pubDate>Tue, 11 Dec 2007 07:31:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083338#M92876</guid>
      <dc:creator>Gyankr</dc:creator>
      <dc:date>2007-12-11T07:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Getting files via sftp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083339#M92877</link>
      <description>Assuming you have keys working from host1 to host2, you could try something like this to determine the most recent file on host2 from host1:&lt;BR /&gt;&lt;BR /&gt;FILES=`ssh host2 find /directory/with/files/ -type f -mtime -1 -name "CMO_LANG_STD_\*"`&lt;BR /&gt;&lt;BR /&gt;cd /local/dir/to/put/file&lt;BR /&gt;for i in $FILES ; do &lt;BR /&gt;  sftp USER@host2:$i .&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;An easier solution would be to sftp the file from host2 to host1.  Then you only need 1 sftp command.  You could use the find command to determine the most recent file.</description>
      <pubDate>Wed, 12 Dec 2007 21:13:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083339#M92877</guid>
      <dc:creator>Autocross.US</dc:creator>
      <dc:date>2007-12-12T21:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Getting files via sftp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083340#M92878</link>
      <description>At the risk of starting a flamewar, I'm not a big fan of any Perl CPAN modules.  I'm not familiar with this one, but I've noticed in that past a recursion problem compiling Perl modules, such that module A needs module B needs module C ...&lt;BR /&gt;&lt;BR /&gt;The biggest problem you face is determing what is the "latest" file.  Instead of using sftp, it might work better with scp with a wildcard:&lt;BR /&gt;&lt;BR /&gt;scp -p remotehost:/remote/dir/CMO.* .&lt;BR /&gt;&lt;BR /&gt;once the file has downloaded, chmod u-w so that the next invocation of scp won't over-write and re-fetch the same file.  The "-p" option will preserve the access times so you can see what the latest version is.</description>
      <pubDate>Mon, 17 Dec 2007 23:26:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083340#M92878</guid>
      <dc:creator>Ben Dehner</dc:creator>
      <dc:date>2007-12-17T23:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Getting files via sftp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083341#M92879</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Ben: At the risk of starting a flamewar, I'm not a big fan of any Perl CPAN modules. I'm not familiar with this one, but I've noticed in that past a recursion problem compiling Perl modules, such that module A needs module B needs module C ...&lt;BR /&gt;&lt;BR /&gt;If you use CPAN to fetch modules you can configure the process to either ask or automatically follow any dependencies.  There is no need to manually "chase" anything.&lt;BR /&gt;&lt;BR /&gt;# perl -MCPAN -e shell&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF... &lt;BR /&gt;</description>
      <pubDate>Mon, 17 Dec 2007 23:37:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083341#M92879</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-12-17T23:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Getting files via sftp</title>
      <link>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083342#M92880</link>
      <description>Thanks for your replies</description>
      <pubDate>Wed, 19 Dec 2007 13:23:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/getting-files-via-sftp/m-p/5083342#M92880</guid>
      <dc:creator>Gyankr</dc:creator>
      <dc:date>2007-12-19T13:23:44Z</dc:date>
    </item>
  </channel>
</rss>

