- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: sftp script assistance
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
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
тАО10-11-2005 07:52 AM
тАО10-11-2005 07:52 AM
sftp script assistance
I'm attempting to automate a process that checks for the existence of files in a top level directory with 4 subdirectories, if it exists, it launches sftp to transfer the file to some location, it validates the send, then deletes the file. The structure would be something like this:
/scproot/dir_out
/scproot/dir_out/dir1
/scproot/dir_out/dir2
/scproot/dir_out/dir3
/scproot/dir_out/dir4
Each subdirectory may contain *.xml file.
I know this is not secure but it is for testing only at this time:
the sftp portion would be something like
#!/usr/bin/bash
HOST='myhost.com'
USER='username'
PASSWD='password'
sftp -i -n $HOST <
binary
cd /dir1/dir2/
put some_file
Can someone help me script this appropriately?
Thanks,
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 08:08 AM
тАО10-11-2005 08:08 AM
Re: sftp script assistance
Why don't just run scp of the directories, if the file exists will be transferred, if not, won't do anything. To delete the file you can use ssh remotehost rm *.
Something like this, is just a help, this wont work:
FILES=`ssh remotehost find /scproot/ -type f | wc -l`
if [ $FILES -gt 0 ]; then
for FILES in =`ssh remotehost find /scproot -type f`; do
REMOTE_CHECKSUM=`ssh remotehost md5sum $FILE`
scp remotehost:$FILES /localdir
LOCAL_CHECKSUM`md5sum /localdir/$FILE`
if [ $REMOTE_CHECKSUM = $LOCAL_CHECKSUM ];then
ssh remotehost rm $FILE
fi
done
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 08:23 AM
тАО10-11-2005 08:23 AM
Re: sftp script assistance
I like what you have there with the MD5 Checksums, however, I need to simply look for the files on the "local" server, then if they exist, sftp them to a "remote" server. I do need to use sftp in this instance (not my choice). I would still like to use the incorporation of the MD5 that you listed but I'm not sure how to do that with sftp.
Thanks,
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 08:40 AM
тАО10-11-2005 08:40 AM
Re: sftp script assistance
You won't be able to do checksum comparations using sftp, but you can do an ls -l after the transfer. All sftp transaction output should be redirect to a file. Then using awk or grep, get the file size and compare it with the local file.
I still think that sshd and scp will do a better job. I know that is not about you, but you should explain that will be more reliable this way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 08:52 AM
тАО10-11-2005 08:52 AM
Re: sftp script assistance
Thanks for the assistance. I'll keep trying to get the information put together for the script.
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-11-2005 09:15 AM
тАО10-11-2005 09:15 AM