Capturing failed FTP error


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Capturing failed FTP error
# 1  
Old 04-19-2007
Lightbulb Capturing failed FTP error

Hi All,

Please check the below ftp related job, which is deleting the files from remote host. Problem is it is not capturing the ftp failure error, and the exit status is still '0' eventhough the deletable files are not present in remote location OR ftp credential are incorrect.



#!/usr/bin/ksh -x

export REMOTEHOST1=10.19.5.221
export REMOTEUSER1='ganap_01'
export FTP_PASSWD='mysore001'
export OUTPUT_DIR='/export/home/ganap'

ftp -n $REMOTEHOST1 <<EOD
user "$REMOTEUSER1" "$FTP_PASSWD"
del $OUTPUT_DIR/aaa.log
del $OUTPUT_DIR/bbb.log
del $OUTPUT_DIR/ccc.log
del $OUTPUT_DIR/ddd.log
bye
EOD

# Checking the success of the FTP call
EXIT_STATUS=$?
if [ EXIT_STATUS -ne 0 ];then
echo FTP Failed
exit 1
fi



Please see the result below:

/export/home/ITC_rlok>ftp*
+ export REMOTEHOST1=10.19.5.221
+ export REMOTEUSER1=ganap_01
+ export FTP_PASSWD=mysore001
+ export OUTPUT_DIR=/export/home/ganap/
+ ftp -n 10.19.5.221
+ 0<<
user "ganap_01" "mysore001"
del /export/home/ganap/aaa.log
del /export/home/ganap/bbb.log
del /export/home/ganap/ccc.log
del /export/home/ganap/ddd.log
bye
/export/home/ganap/aaa.log: No such file or directory.
/export/home/ganap/bbb.log: No such file or directory.
/export/home/ganap/ccc.log: No such file or directory.
/export/home/ganap/ddd.log: No such file or directory.
+ EXIT_STATUS=0
+ [ EXIT_STATUS -ne 0 ]



I dont know, how to handle this. Please suggest/guide me.

With Regards,
Mysore Ganapati.
Smilie

Last edited by ganapati; 04-19-2007 at 06:43 AM..
# 2  
Old 04-19-2007
thats the return status of the ftp session established,
since it had completed successfully, the return status is 0

ftp session return status overrides the return status of the commands executed within the ftp session.

To acheive that, possible way could be redirect the ftp logs ( commands issued, output received from the ftp server )
once the ftp session is done,
parse the log,
to identify the operation was successfull or not
ftp return codes are available and with that it should be easier to identify the status of the operation
# 3  
Old 04-19-2007
Lightbulb

Thanks for reply matrixmadan,

Then, what is the use of checking the exit status of the ftp command?
Can I skip the below testing block? When this can be used? Are there any other way to exit this condition with the exit status '1'? Smilie

EXIT_STATUS=$?
if [ EXIT_STATUS -ne 0 ];then
echo FTP Failed
exit 1
fi


Cheers~~
Ganapati.
# 4  
Old 04-19-2007
Lightbulb

Also Iam not getting any log file for this ftp process.
Where can I find this log file or how do I create this?

Can any one help me. Smilie

Thanks in advance,
Mysore Ganapati.
# 5  
Old 04-19-2007
Quote:
Originally Posted by ganapati
Also Iam not getting any log file for this ftp process.
Where can I find this log file or how do I create this?

Can any one help me. Smilie

Thanks in advance,
Mysore Ganapati.
you can put >> logfile at :
Code:
...
ftp -n $REMOTEHOST1 <<EOD >> logfile.txt
...
EOD

for more verbose output, you can put -d (debugging) if your ftp client supports debugging mode
eg
Code:
...
ftp -d -n $REMOTEHOST1 <<EOD >> logfile.txt
...
EOD

# 6  
Old 04-19-2007
Quote:
[...]
I dont know, how to handle this. Please suggest/guide me.
1. Use different client.

2. Use something like this (change the process substitution with pipe, if your shell doesn't support it):

Code:
ftp -n your_host < <(printf "%s\n" "user your_user your_pass" "get your_file" "quit")>err;\
[ -s err ]&&exit 1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script for capturing FTP logs

I have a script #!/bin/bash HOST=ftp.example.com USER=ftpuser PASSWORD=P@ssw0rd ftp -inv $HOST <<EOF user $USER $PASSWORD cd /path/to/file mput *.html bye EOF the script executes sucessfully I need to capture the FTP logs to a logfile should contain FTP Login successful ... (1 Reply)
Discussion started by: rajeshas83
1 Replies

2. UNIX for Dummies Questions & Answers

FTP failed

Hi All, We are using the following step to place a file in server using FTP STEP_EXECUTE STEP090 /usr/pjc/bin/FTP -i DATASET FTPIN $sic/ctl/ftpsic.ctl DISP=OLD,KEEP,KEEP STEP_END If we run this step we are getting the error. ftp> open arg.mnd.appsc.com Connected to arg.mnd.appsc.com.... (4 Replies)
Discussion started by: ajaykumarkona
4 Replies

3. Shell Programming and Scripting

Capturing FTP logs

Hi Guys, I am trying to capture the FTP Logs in a log file. I am using the below code. ftp -d -n -v $Remote_Host << EOD > $Ftp_LOG; Since iam running the script in debug mode, i am able to see that the ftp is done and the file has been transferred. But the log file does not have... (7 Replies)
Discussion started by: mac4rfree
7 Replies

4. Solaris

Cygwin X Server error: xdmcp fatal error session failed session 23 failed for display

Hi, i got the following error when i tried to access the cygwin x server from a windows XP PC. "xdmcp fatal error session failed session 23 failed for display" Alternatively, when i tried to access the same Cygwin X Server from another windows XP PC which is on a different LAN... (3 Replies)
Discussion started by: HarishKumarM
3 Replies

5. UNIX for Dummies Questions & Answers

FTP: Error -140: remote mkdir failed

I've just installed vsftpd on Ubuntu 9.04 server. I can access using my ftp client, however I cannot use mkdir either upload files. I get the following errors: `Error -140: remote mkdir failed` My configuration file has: write_enable = YES Is there some other parameter I should... (2 Replies)
Discussion started by: aneuryzma
2 Replies

6. Shell Programming and Scripting

automatic FTP failed

I have automated ftp for different scripts. every script uses different login and passwords for different server. it reads the username and password from netrc. there is 1 particular script that is failing. this script is failing in FTP step. i have checked the logs it says login failed. but... (5 Replies)
Discussion started by: dazdseg
5 Replies

7. Solaris

FTP login failed.

Hi guys, Can you please help me. I have SUN V100 server running solaris 8. I also have a Redhat Linux 6.2 machine and a windows XP machine on the network. I'm trying to copy files from the Linux and XP machines to the V100 server. When I try to ftp to the solaris machine, I'm challenged... (2 Replies)
Discussion started by: Stin
2 Replies

8. UNIX for Dummies Questions & Answers

Capturing FTP log

I am trying to do the FTP using .netrc.In my .netrc file in $HOME dir i am placing the machine ip,user name and pwd.Then i am creating dynamically a file which contains the ftp commands. My script is like below: __________________________________ export REMOTE_DIR= <some path> export... (4 Replies)
Discussion started by: dr46014
4 Replies

9. AIX

ftp check for failed attempts

Hi, I have created the below ftp script to put files over to our capacity server, the check at the end works if ftp fails to run however if the script cannot login or the transfer itself failed there is no warnings. Does anyone know the syntax to trap the erorr codes or to put a check within... (3 Replies)
Discussion started by: chlawren
3 Replies

10. Shell Programming and Scripting

failed to access directory thru ftp

Hi all, I am a beginner to unix and ftp too.So i request your valuable comments. Requirement: I want to put a specific file into a server(linux) and under a particular directory path in that server as /caps/details/data/ Problem : I login to that server through the command `ftp... (1 Reply)
Discussion started by: DILEEP410
1 Replies
Login or Register to Ask a Question