displaying error while automating ftp


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users displaying error while automating ftp
# 1  
Old 10-31-2006
displaying error while automating ftp

#!/bin/sh

HOST=HOST_IP
USER=$USER
PASSWD=$PASSWD
FILE="*.htm"

ftp -n $HOST <<END_SCRIPT

quote USER $USER
quote PASS $PASSWD
get $FILE
quit
END_SCRIPT
exit 0



Is there any way to display appropriate error message if the file is not found on the server......
# 2  
Old 11-01-2006
With verbose on 550 is the error returned for a file not found:
Code:
HOST=HOST_IP
USER=$USER
PASSWD=$PASSWD
FILE="*.htm"

ftp -n $HOST <<END_SCRIPT

quote USER $USER
quote PASS $PASSWD
verbose
get $FILE
quit
END_SCRIPT  | grep -q  "550 $FILE" 
if [[ $? -eq 0 ]] ; then
     echo "$FILE not found"
fi
exit 0

# 3  
Old 11-02-2006
Quote:
Originally Posted by jim mcnamara
With verbose on 550 is the error returned for a file not found:
Code:
HOST=HOST_IP
USER=$USER
PASSWD=$PASSWD
FILE="*.htm"

ftp -n $HOST <<END_SCRIPT

quote USER $USER
quote PASS $PASSWD
verbose
get $FILE
quit
END_SCRIPT  | grep -q  "550 $FILE" 
if [[ $? -eq 0 ]] ; then
     echo "$FILE not found"
fi
exit 0


After trying the above code it didn't work.
I hope, is there any method to trap the error codes in a variable...?
please modify the code with the above code with the suggestion.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ls command in a for loop displaying error

I have a few files inside a directory and in my code i am listing the files to get the filenames and do further operations.Details are given below: Dirname is taken as argument in $3 and filenames in variable $file Directory name =$3= /tmp/to-be_parsed/input Filename= $file=... (8 Replies)
Discussion started by: Jag02
8 Replies

2. UNIX for Dummies Questions & Answers

Find Null values in Columns and fail execution by displaying error message

Hi All, I am new to shell scripting. I have a requirement as part of my job to find out null/empty values in column 2 and column 3 from a CSV file and exit the further execution of script by displaying a simple error message. I have developed a script to do this by reading various articles... (7 Replies)
Discussion started by: tpk
7 Replies

3. UNIX for Dummies Questions & Answers

Automating the FTP get

Hi , I want to pull files from ftp monthly once . The files in ftp has a something like 292_fileto_pull and next month it will be 293_fileto_pull for each month the number keeps increasing. i thought in my script if i can use date and increment the number by it mget *_292_fileto_pull i... (2 Replies)
Discussion started by: vikatakavi
2 Replies

4. Shell Programming and Scripting

Help with FTP Script which is causing "syntax error: unexpected end of file" Error

Hi All, Please hav a look at the below peice of script and let me know if there are any syntax errors. i found that the below peice of Script is causing issue. when i use SFTP its working fine, but there is a demand to use FTP only. please find below code and explain if anything is wrong... (1 Reply)
Discussion started by: mahi_mayu069
1 Replies

5. Ubuntu

error in displaying filesystem %

Hi, The below command is expected to display the filesystem along with the used % and available % in each of the filesystem in the linux box. df -k / | grep -v 'capacity' | gawk '{ print $5 }' But instead of displaying the actual used %, it is showing as 'Use%'. Could anyone please let... (2 Replies)
Discussion started by: lg123
2 Replies

6. UNIX for Dummies Questions & Answers

Automating ftp job using implicit ssl?

Can this be done? Or do you need some other program installed on the AIX box? (6 Replies)
Discussion started by: NycUnxer
6 Replies

7. Shell Programming and Scripting

FTP Error 553 I/O error.

Hi All, I have a problem when uploading txt file from windows to Unix server. I got 533 I/O error. I am using .bat file and it works for other batches but with this particular batch it doesn't work. thanks guys for helping in advance. (2 Replies)
Discussion started by: sfaqih
2 Replies

8. Shell Programming and Scripting

Automating ftp without .netrc

I'm writing a script which needs to run under an 'automation' account and there is already a .netrc machine definition for the server I need to connect to. If I create a new machine entry in the .netrc with a different account this will, of course, be ignored and the ftp session will connect to... (3 Replies)
Discussion started by: DeepakS
3 Replies

9. Shell Programming and Scripting

Automating telnet and ftp

Hi, I want to automate FTP. I have a fair idea that this can be done using expect scripting. But I dont how to do it. Please, can anyone give me an example of how to do it in Unix. Thanks in advance (2 Replies)
Discussion started by: sendhilmani123
2 Replies
Login or Register to Ask a Question