Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with ftp

Status
Not open for further replies.

lorel

MIS
Jun 15, 2004
158
I have the need to transfer files unattended between different systems in different locations. I have written a small scrip using ftp that does this fine.

My problem: If the internet is not working in the site for the transmitting server or the network number of the receiving system is wrong, ftp will seat there for ever and never times out. Being this an utility that runs in the middle of the night, I need for it to detect that is not connecting and take appropriate action.

I my research I have not been able to find a solutions to this problem.

Can any one provide me with some ideas?

Thanks in advance to a any one who takes the time to answer my question.

Joe
 
Can you normally ping the server? If so, you can do a ping, limit the number of packets, send the output to /dev/null and check to see if that was sucessful before going on with the ftp. You can even do a loop that would continue doing that (with a healthy pause) until it was successful.

Other option would be to look at the ftp manpage and specify a timeout for the command. If SCO's ftp doesn't have it, I would recommend the ncftp client (use the connect-timeout variable).

You could also use scp (or sftp) for the transaction, as they also have the provisions for connection timeout.

Best of luck!
 
The main server can not be ping, the firewall is setup to prevent this.
We have over 200 clients running our software, due to the type of software, it requires frequent updates. The script we have develop will call the main server (ours) and download the updates and installs them.
Since some of our client are using old version of SCO UNIX, they may not have ssh or sftp. In addition, there is the question of the authentication keys are are to be setup in order to use sftp in batch mode.
We are planning to upgrade all our clients to the latest level of UNIX in the near future, this may not be completed until the end of next year.
In the interim, we are going to ping a site like Microsoft of Yahoo and use their response to make sure the client internet is working. It is not a perfect solution but is workable until we are able to upgrade the client's server to a level that will allow the use of sftp.

In any case, thanks Edcrosbys, for taking the time to answer my question.

Joe
 
Another option you have is to run a background process when the FTP job starts. It can sleep for, say, 1800 seconds, and if it detects that the FTP job is still hanging, kill it and report an error message. If the FTP completes successfully, it kills the background job (or just allow it to terminate in its own good time).

Annihilannic.
 
Annihilannic:

That is a good subjection! We are trying different things, including setting up a tpc/ip phantom address in our site, but your idea intrigues me and may be easier to setup.

Thanks

Joe
 
Another option is to use curl for the transfer instead of ftp.
Curl can use the ftp transport and has a --connect-timeout option.
 
You could install 'expect' command wrapper from the SCO skunkware site and set a, say, 60 second timeout while waiting for the initial response.

'expect' would also give you some powerful tools to automate plain old ftp.

It uses the Tcl command set, but at it's simplest it launches some command and stays in the background looking for specific responses, then takes actions based on that response.

----------------------------------------------------------------
Pat Welch, UBB Computer Services, a WCS Affiliate
SCO Authorized Partner
Microlite BackupEdge Certified Reseller
Unix/Linux/Windows/Hardware Sales/Support
(209) 745-1401 Cell: (209) 251-9120
E-mail: patubb@inreach.com
 
What version of perl can you expect to see? I believe perl has had ftp timeout options in there for awhile...

If not, since you are providing the script to update the boxes, you could bundle the required perl libraries/executables as well...

OR maybe this would be a good place to write a quick c program (either ftp or ssh libraries are out there). This could provide a secure, configurable transmission regardless of the programs available on the host machine. This is especially attractive if you have access to programmers (although it isn't too tough if you aren't a programmer).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top