I have a pretty demanding requirement for an SFTP script I have been trying to put together.
I have nearly 100 files (all with the names staring with T_PROD) generated in my local server daily. I need to transfer each of these files to a remote server via SFTP (that's a client demand, can't use SSH or others). Since these files are pretty big (approx 10 MB each), we need to have a check on succesful transfer of each of the files. In case a file is not transferred properly, we will be trying to re-send the file, at max 3 times.
Since it's SFTP, we're not allowed to execute shell commands in the remote server. I tried creating the md5sum hash values, but stuck thereafter. How do we identify the exact files those failed the sanity check, and try re-sending them?
A barebone structure of the script is as below
I'm running this script in Linux kernel 2.6.39
Do let me know if any further information is required.
Your sftp session is not a normal shell session for running commands remotely so it is a little awkward. You command below
will run on the local server, so I'm not sure that is what you really want.
If you were using plain ftp then you would get a zero return code if the connection opened and you had to resort to switching on flags to get more verbose output that can be captured in a log file and read afterwards. sftp on the other hand is better with errors. Could you do something like the following instead?:-
I'd say sftp is a secure and safe protocol. It either succeeds or it doesn't. Run it with raised logging level (-v option) . Check the exit code after completion.
Run it for each file and check the exit code, log errors as appropriate.
Hi achenle, as I've said in my first thread, using SFTP is a business requirement, and we can't help abiding by that.
Quote:
Originally Posted by rbatte1
Welcome Aviktheory11,
Your sftp session is not a normal shell session for running commands remotely so it is a little awkward. You command below
will run on the local server, so I'm not sure that is what you really want.
If you were using plain ftp then you would get a zero return code if the connection opened and you had to resort to switching on flags to get more verbose output that can be captured in a log file and read afterwards. sftp on the other hand is better with errors. Could you do something like the following instead?:-
Thanks for the help rbatte1. However, will just checking the return code of sftp ensure the correct transfer of files ? I'm dealing with file transfer things just recently [that's why I've used the md5sum, din't realise it worked only locally], and I believe the return code is 0 even if a file was transferred partially. Please correct me if I'm wrong.
I'll try out your suggestion though. Thanks a lot for the help again !!!
You could also list the file catching the output and comparing it later. Use an embedded dir $file in your script after you send the file. You can compare the number of bytes with the original file.
Unfortunately in this case sftp is pretty robust. I will see if I can test it out by sending a large file and then killing the sftpd process on the remote side to see what happens when I get a chance (unless anyone else would care to have a go first)
Hi Guys,
I have performed OBP & ALOM upgrade on V240 system. One of my system, running Solaris 10, having issue to identify flash rom during ALOM 1.6.10 version upgrade (OBP upgraded to latest one).
May I know what the reason of this error and how can I fix it so I can upgrade ALOM using... (0 Replies)
I am working on a shell script where after making sftp connection to a remote server the file are being transferred. The problem is how to capture return code for the file which is missing at the remote location. I have tried to capture the return code which return value of "0" even the transfer of... (4 Replies)
hi,
how can i know whether a command inside an sftp script has failed or not?
i have a sftp expect script
#!/usr/bin/expect
spawn /usr/bin/sftp abc@ftp.abc.com
expect "sftp>"
send "cd dir\r"
expect "sftp>"
send "mput abc.txt\r"
expect "sftp>"
send "mput def.xls\r"
expect "sftp>"... (5 Replies)
I would like to create console application in c# to automate the process of downloading some files from a SFTP server to my local hard drive at a set time each week/day.
SFTP Server installed OpenSSH for windows and client machine also.
Any ideas how I could do such a task? or sample code.
... (0 Replies)
Good Evening,
2 years ago, I set up an Ubuntu file-server for a friend, who is a photograph amateur. Basically, the server offers a software RAID-5 that can be accessed remotely from a MAC. Unfortunately, I didn't labeled the hard drives (i.e. which physical drive corresponds to the /dev/sdX... (2 Replies)
Hi friends,....
am sindhiya,
i have joined as AIX level 1 support.
help me to identify the failed pv in vg which has some 4 physical volumes? (2 Replies)
Hi,
While I am trying SFTP my machine to another unix machine ,
it was working fine till 10 min back.
But now i am getting the below error
"Request for subsystem 'sftp' failed on channel 0"
Could you please someone help me to solve or analyise the root cause...
Cheers:b:,
Mahiban (0 Replies)
I get this error when I try to FTP from an HP Alpha Server to a UNIX box.
FATAL: BUILD13$:SSHFC_TRANSFER.C;1:1835 SshFCTransfer (function name unavailable) Assertion failed: tdata
->current_dest_file->attributes->flags & 0x00000004
the sftp /put fails just before it does the actual transfer.... (2 Replies)