verify ftp status is "good"


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting verify ftp status is "good"
# 1  
Old 03-28-2002
Question verify ftp status is "good"

Hello,
From reading prior "threads", my script looks like this:

#!/bin/ksh -x
ftpresults=`ftp -nv $ftphost1 << EOB
user $ftpuser $ftppwd
put $ftp_file $ft
put $ftp_file $ft1
bye
EOB`
ftp_ctr=`echo $ftpresults | grep "226 Transfer complete" | wc -l`
echo $ftp_ctr
If [ $ftp_ctr = 2 ]
then
...
else
...
fi

I want to make sure that I have successfully ftp'd two files. The $ftp_ctr returns 1; while it should be 2. Any ideas why this code only returns 1 and not 2. I ftp'd two files, there are two instances of "226 Transfer complete" in the variable $ftp_ctr.

Also, is there a better way to check for a successful ftp?

Thanks in advance for your help! This site is great!
# 2  
Old 03-28-2002
I'm betting that because you are putting all the information into a variable, that it is all one line - since you are counting how many LINES have the successful transfer, it's only 1 everytime (although there are two occurances in the one line).

The other problem is if you ftp to a site that has a huge banner before you ever do a login, all of that is saved into your variable. Possible that you would overload it and your script would bomb out and you would never know why.
thehoghunter
# 3  
Old 03-28-2002
Re: verify ftp status is "good"

Try double quotes around the results:
ftp_ctr=`echo "$ftpresults" | grep "226 Transfer complete" | wc -l`
# 4  
Old 03-28-2002
Hammer & Screwdriver

Thank you - it works!
# 5  
Old 04-02-2002
remote_file_size=`grep $file file.log | awk ' { print $5 } '`
local_file_size=`l | grep $file | awk ' { print $5 } '`

echo "CHECKING TRANSFER"
echo "remote size $remote_file_size local size $local_file_size"
if [ $remote_file_size = $local_file_size ] ; then
echo "TRANSFER WAS SUCCESSFUL!"
mail -s "File Transfer Complete" jamison < ftp.log
/otl/otlcap/bin/cdpager 0011
fi
if [ $remote_file_size != $local_file_size ] ; then
echo "TRANSFER FAILED!"
mail -s "File Transfer Failed" jamison < honda_ftp.log
/otl/otlcap/bin/cdpager 0010


i grep the file size on both their system and mine, compare them all, then i echo out a message, email me a message, and also page me. when dealing with 400+ meg files its nice to be alerted no matter where i am
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

Verify the variable has "space" or not?

How to check if a variable contains space in it??? or any other character??? using if condition.. (5 Replies)
Discussion started by: karthikeayan
5 Replies

4. Solaris

"Solaris" - A very good example of a very bad subject title

Any body known this command uadmin 2 (2 Replies)
Discussion started by: Rajesh_Apple
2 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. UNIX for Dummies Questions & Answers

Why is creating an RCS archive in /etc a "good thing"??

Hi guys, Why is creating an RCS archive in /etc a "good thing"?? (1 Reply)
Discussion started by: lemon_06
1 Replies

7. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

8. Solaris

"Error for Command: verify"

I have a raid 5 configuration in a A3500 rack, manager by raid manager. This morning I found this messages in a /vad/adm/messages": Sep 10 04:33:57 zion scsi: WARNING: /sbus@3,0/SUNW,socal@2,0/sf@1,0/ssd@w200200a0b80735d3,4 (ssd11): Sep 10 04:33:57 zion Error for Command: verify ... (1 Reply)
Discussion started by: bonovox
1 Replies

9. UNIX for Dummies Questions & Answers

Good unix "for lamers/beginners" book?

Im pretty new to unix, as you can probably tell. Anyway I want to get a book on unix and howto use it. I would like to get a book that goes from the very basics to the advanced things that unix can be used for, does anyone have any suggestions?? (16 Replies)
Discussion started by: MadProfessor
16 Replies
Login or Register to Ask a Question