FTP - need to send error to txt file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers FTP - need to send error to txt file
# 1  
Old 10-23-2007
FTP - need to send error to txt file

I've written a script to FTP files into a directory, perform a diff between the current and the previous and email out the results. Sometimes a machine falls off the network and needs to be rebooted to reconnect. Obviously I don't get the file I want at that time. How do I get the FTP error to be written to a file that I can send out with the email?

I'm working on an HP-UX system if that helps answer the question.

Here's the section of code that's of concern.

cp blank.txt ${tool}/errorlog.current
ftp -i nsr100 <<EOF
get ${tool}\"mcsv\ pass\"::[mcsvlog]log_err.log ${tool}/errorlog.${now}
quit
EOF
diff ${tool}/errorlog.${yesterday} ${tool}/errorlog.${now} >> ${tool}/errorlog.current


When it fails I get this output on my screen:
Failed to open file.
diff: input file nsr3/errorlog.Oct19: No such file or directory

So basically what I need to do is if the FTP returns an error, write a line to a file that says "no current logfile from ${tool}. ${tool} has likely fallen off the network. Please investigate and correct."

Thanks in advance.
# 2  
Old 10-25-2007
Ftp Error Log

Redirect standard error (filehandle 2) to an errorlog

FTPOUT=/tmp/ftperr.out
#Initalize file
>$FTPOUT

ftp -i nsr100 <<EOF 2> $FTPOUT
...
EOF
# Check if file size greater then zero
if [ -s $FTPOUT ]
then
#Do something
fi

If your transfer had no errors then the file size will be zero
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Converting txt output to rows and columns and send report via mail.

Hi All, I would like to send below output in a tabular column ( xml or excel ) and send a mail. vinay unix anil sql vamsee java request to suggest a solution. (1 Reply)
Discussion started by: Girish19
1 Replies

2. Shell Programming and Scripting

awk append fileA.txt to growing file B.txt

This is appending a column. My question is fairly simple. I have a program generating data in a form like so: 1 20 2 22 3 23 4 12 5 43 For ever iteration I'm generating this data. I have the basic idea with cut -f 2 fileA.txt | paste -d >> FileB.txt ???? I want FileB.txt to grow, and... (4 Replies)
Discussion started by: theawknewbie
4 Replies

3. Shell Programming and Scripting

Shell script to send an email from the txt file

Hi Friends, Could you guys help me out of this problem... I need to send an email to all the users and the email has to be picked from the text file. text file contains the no. of records like: giridhar 224285 847333 giridhar276@gmail.com ramana 84849 33884 venkata.ramana@gmail.com... (6 Replies)
Discussion started by: giridhar276
6 Replies

4. UNIX for Dummies Questions & Answers

Copying dir (and sub dir) file names from ftp server to txt file in diff server

Hey all, i want to copy only the file names from an ftp server (directory and all sub directory) to a text file in another server (non ftp), i.e. i want to recursively move through directories and copy only the names to a text file. any help is appreciated...thank you in advance (1 Reply)
Discussion started by: deking
1 Replies

5. UNIX for Dummies Questions & Answers

Binary txt file received when i use uuencode to send txt file as attachment

Hi, I have already read a lot of posts on sending attachments in unix...but none of them were of help for my problem...so here goes.. i wanna attach a text file and send to a mail id..used the following code : uuencode "$File1" "$File1" ;|mail -s "$Mail_sub" abc@abc.com it works... (2 Replies)
Discussion started by: ash22
2 Replies

6. Shell Programming and Scripting

FTP - need to send error to txt file

I've written a script to FTP files into a directory, perform a diff between the current and the previous and email out the results. Sometimes a machine falls off the network and needs to be rebooted to reconnect. Obviously I don't get the file I want at that time. How do I get the FTP error to... (0 Replies)
Discussion started by: scanner248
0 Replies

7. Shell Programming and Scripting

Parse the .txt file for folder name and FTP to the corrsponding folder.

Oracle procedure create files on UNIX folder on a regular basis. I need to FTP files onto windows server and place the files, based on their name, in the corresponding folders. File name is as follows: ccyymmddfoldernamefile.txt; Folder Name length could be of any size; however, the prefix and... (3 Replies)
Discussion started by: MeganP
3 Replies

8. Shell Programming and Scripting

How send a file from UNIX to Windows with FTP

Hi I'm new working in UNIX, So, I want to know How I can send a file from UNIX to Windows server with FTP. This is my script. ftp -i -n -v <<** open 199.99.99.99 user user1 password1 lcd C01_07_06 /* source/ cd //199.98.98.98/group1/reports /*destination*/ put file1.sh ... (1 Reply)
Discussion started by: edzela
1 Replies

9. Shell Programming and Scripting

send file of size 0 with FTP on AIX

I'm using IBM AIX 5.2 to send file with ftp to other unix machine. The command is into a shell: ... ftp -n > outFtp 2> errFtp <<PARAM open $2 user $3 $4 put $1 $remote bye PARAM ... then i look at the size of errFtp and outFtp to see if there are some error message.... (4 Replies)
Discussion started by: gggarb
4 Replies

10. UNIX for Dummies Questions & Answers

Send a file by ftp

Hello! Is there any chance that this single line command execute properly on aix? I have 0 knowledge on that platform!! echo "User_FTP \nFTP_PASSWORD \nbin \ncd cad \nput /opt/lotus/office/general/Agent.csv \nquit" | ftp abc0.cie.com If not, any other suggestion? A single line command... (4 Replies)
Discussion started by: jr_provost
4 Replies
Login or Register to Ask a Question