- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Getting files via sftp
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2007 07:10 AM
тАО12-07-2007 07:10 AM
Getting files via sftp
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.
Regards,
Gyan
- Tags:
- sftp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2007 07:48 AM
тАО12-07-2007 07:48 AM
Re: Getting files via sftp
http://search.cpan.org/~dbrobins/Net-SFTP-0.10/lib/Net/SFTP.pm
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2007 08:07 AM
тАО12-07-2007 08:07 AM
Re: Getting files via sftp
You could get the file like this (on local host):
cd /local/dir/to/put/file
sftp USER@host2:/path/to/remote/file .
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-10-2007 11:31 PM
тАО12-10-2007 11:31 PM
Re: Getting files via sftp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-12-2007 01:13 PM
тАО12-12-2007 01:13 PM
Re: Getting files via sftp
FILES=`ssh host2 find /directory/with/files/ -type f -mtime -1 -name "CMO_LANG_STD_\*"`
cd /local/dir/to/put/file
for i in $FILES ; do
sftp USER@host2:$i .
done
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-17-2007 03:26 PM
тАО12-17-2007 03:26 PM
Re: Getting files via sftp
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:
scp -p remotehost:/remote/dir/CMO.* .
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-17-2007 03:37 PM
тАО12-17-2007 03:37 PM
Re: Getting files via sftp
> 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 ...
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.
# perl -MCPAN -e shell
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2007 05:23 AM
тАО12-19-2007 05:23 AM