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!

catch ftp error

Status
Not open for further replies.

marghe

Instructor
Apr 5, 2004
13
IT
I have to do a ftp script to put some file from a SCO-UNIX OPEN SERVER to another SCO-UNIX OPEN SERVER.
The script is
ftp -in Destination <<END_FTP
user login psw
bin
put file destination
bye

How can i catch the error?
in Connection and puttin file
Thanks
Dax
Sorry for my English

 
Code:
ERRFILE="/tmp/ftp_errors.txt"

ftp -in Destination <<END_FTP > $ERRFILE
user login psw
bin
put file destination
bye
END_FTP

cat $ERRFILE | mailx -s "FTP Errors" marghe@tek-tips.com

--
-- GhodMode
 
Thanks, but I use my script in crontab, then I've to execute something that I can catch from it.
Is it possible?
Bye
Dax
 
When running under cron, turn on verbose ftp -v and then grep for code 226 successful transmission, e.g.
[tt]
if grep -q 226 $ERRFILE
then
: ok
else
: error
fi

[/tt]
 
This is the script's text

ftp -in Destination <<END_FTP
user login psw
bin
put file destination
bye

why ftp don't accept the password but it stops and answer me it?
Bye
 
where's your closing END_FTP of the here-doc?

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
ftp -in Destination <<END_FTP
user login psw
bin
put file destination
close

Sorry, close rest in my cut and paste

 
marghe,

Vlad is referring to the line to end the here document.

The last line should say:

END_FTP

John
 
Take a look at the GhodMode's post for a proper here document.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Sorry, Do you want to say that I must Start a Thread with subject : "Why my ftp script's don't login?"
Bye
DAx
 
No - a 'here document' is a expression in scripts.
Instead of using a file, you read from 'here' which is 'there' 'where' your script is.
You give a keyword, which indicates the EOF, END_FTP in your case, but your script doesn't show a END_FTP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top