Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

wesg

macrumors regular
Original poster
Jan 2, 2008
211
0
Toronto, ON
I'm writing a bash script that eventually will upload to my website, and I've run into a problem with the FTP element.

Whenever I login with the command
Code:
ftp ftp://user:password@www.example.com

I get the response Invalid number of arguments, and it disconnects me. What am I doing wrong?
 

telecomm

macrumors 65816
Nov 30, 2003
1,387
28
Rome
It's been a while since I've done anything ftp related from terminal, but I think you just want 'ftp username@location' (so try it without the 'ftp://' bit).
 

wesg

macrumors regular
Original poster
Jan 2, 2008
211
0
Toronto, ON
I've solved one problem, but now I need to build in error detection. My script will be running with crontab every hour, but if I'm not connected to a network, I don't want it to hang. How can I set a timeout so the script continues after, say, 5 seconds of nothing?

Code:
set timeout 10
?
 

shadowfaux

macrumors newbie
May 19, 2008
8
0
I've solved one problem, but now I need to build in error detection. My script will be running with crontab every hour, but if I'm not connected to a network, I don't want it to hang. How can I set a timeout so the script continues after, say, 5 seconds of nothing?

Code:
set timeout 10
?

I think the -q option to ftp will do the trick:
Code:
ftp -q 30 ftp://user:pass@host:port/

but the man page reads "Quit if the connection has stalled for quittime seconds." so it may only start counting after a connection is made.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.