Computing.Net > Forums > Unix > ftp in shell script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

ftp in shell script

Reply to Message Icon

Name: KS
Date: July 12, 2001 at 00:43:48 Pacific
Comment:

I need to know if the connection fails to the remote host in a shell script. Which error codes etc should I check for? What would be in the if statement?
example, I use:
ftp -n -i <<-EXIT
open $REMOTE_HOST
if ??????????



Sponsored Link
Ads by Google

Response Number 1
Name: stefan caunter
Date: July 17, 2001 at 19:44:47 Pacific
Reply:

what you need to do is test for the exit status of the ftp command in a subshell
first set a variable to be the exit status of ftp -n -i; if it is 0 everything is ok, if it is greater than 0, problem. soooo....

$var=`(ftp -n -i $REMOTE_HOST; echo $?)`
if [$var -eq 0] ; then
user xxxxx
pass xxxxx
elif [$var -gt 0] ; then
echo "Could not connect to $REMOTE_HOST"


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: ftp in shell script

ftp shell script skip login www.computing.net/answers/unix/ftp-shell-script-skip-login/4887.html

loops in shell scripts!!! www.computing.net/answers/unix/loops-in-shell-scripts/5140.html

Using hex-code in shell script www.computing.net/answers/unix/using-hexcode-in-shell-script/4227.html