Detecting a successfull FTP connection


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Detecting a successfull FTP connection
# 1  
Old 09-29-2005
Detecting a successfull FTP connection

I have a question. My company has to send a file to another company. The cron script currently just sends the file. However, every now and then the other companies ftp server is down. I wanted to alter my script to detect if the server is up before I attempt to send the file. My idea follows

# Check to see if xxx ftp application is working
ftpResponse=`ftp -n -v XXX.XXX.XXX.XX < $GERS_HOME/adhoc/arcr/FTPCHK.ftp`

#echo "$ftpResponse"

ftpnum=`echo "$ftpResponse"|grep 230 | wc -c`

#echo $ftpnum

if [ $ftpnum -gt 0 ] ; then
.....
fi



The ftp sites IP number does not contain the number 230 . The current response from the server is below. Do you think that this would be a robust method or do you have a more robust method?

Connected to XXX.XXX.XXX.X.
220 xxx_FTP1
331 Password required for XXXXXXX.
230 User XXXXXXX logged in.
221 Bye bye ...

Meaning of the returned FTP codes.
220 Service ready for new user.
331 User name okay, need password.
230 User logged in, proceed.
221 Service closing control connection. Logged out if appropriate.
# 2  
Old 09-29-2005
y dont u ping

I think your method is robust enough.

alternatively, just use

ping yourserver -c 1 1>/dev/null 2>/dev/null
if [ $? -eq 0 ]
then
echo "server up"
else
echo "server down"
fi

This will show if 'yourserver' is running.
# 3  
Old 09-30-2005
I should have mentioned that I wanted to make sure the FTP service is up, not just the server. My bad...

I will go with my method.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Debian

ftp connection refused

I have two computers running Debian 6.0 and one running Solaris 2.6 on a private network. The Debian computers can ftp to the Solaris computer but if a Debian computer is the destination the ftp connection is refused. I assume this is some security feature of Debian. What can I do to allow... (2 Replies)
Discussion started by: snorkack59
2 Replies

2. Solaris

Solaris 10 ftp connection problem (connection refused, connection timed out)

Hi everyone, I am hoping anyone of you could help me in this weird problem we have in 1 of our Solaris 10 servers. Lately, we have been having some ftp problems in this server. Though it can ping any server within the network, it seems that it can only ftp to a select few. For most servers, the... (4 Replies)
Discussion started by: labdakos
4 Replies

3. HP-UX

ftp first connection closed

Hi, Have anyone seen this problem, there is one remote side where their ftp connection to our server will always fail with connection closed by remote host and the second connection will be working. is this an OS issue or network issue? Thanks Robert (4 Replies)
Discussion started by: robertngo
4 Replies

4. Shell Programming and Scripting

FTP connection problem

I am getting the error in this command when i am pitting it in shell script ftp -nvi jcmpcor1.abc.com >/work/test98.dat << EOD error:- invalid command. but when i am writting it from outside it work fine. (7 Replies)
Discussion started by: ravi214u
7 Replies

5. UNIX for Dummies Questions & Answers

FTP Connection

Hi, Anyone encounter whereby when you FTP from an Unix server (Solaris 8) to another server (Window Server 2003), you tend to wait a long while when you do a "ls" and you get a timeout after that. However, when you FTP again and do a "ls", the result of "ls" shown immediately. All connection are... (5 Replies)
Discussion started by: ahlude
5 Replies

6. SCO

ftp connection

I have problem with ftp connection on SCO UNIX 5.0.7, it is work slowly. How I can make accelerate. (6 Replies)
Discussion started by: draganmi
6 Replies

7. Solaris

solaris 10 isnt detecting my internet connection

I installed solaris 10 on my desktop pc, however it does not detect my internet connection. IM also running redhad and that detects it automatically, so i guess i have to go in manually and change something. Im new to all this however and i have no idea how to proceed. (5 Replies)
Discussion started by: stride6
5 Replies

8. Cybersecurity

FTP Connection

I just started a new job and inherited a Fedora core 3 server. I wanted to open the ftp ports and I wanted to verify this code before I mess things up. From my reading the two lines below should allow ftp access can anyone confirm my attempt. iptables -A INPUT -p tcp - sport 21 -m state - state... (0 Replies)
Discussion started by: mungaz
0 Replies

9. Shell Programming and Scripting

Detecting data loss during FTP

Hi, How we can detect that there has been a data loss during FTP, throught Shell scripting? I have gone through FTP return codes, but, none indicate that there has been any data loss. Can we use FTP return code 226 as an indication that during file transfer there has been no data loss? If,... (4 Replies)
Discussion started by: sameerbo
4 Replies

10. IP Networking

FTP connection problem

We have moved our DNS and DHCP to Windows 2000 from BIND. Our FTP Server is running Solaris 2.6, users who receive an i.p. address from win2k DHCP receives a connection failed error when trying to FTP and users who have static i.p. address can FTP with no problems. Can anyone shed light as to... (11 Replies)
Discussion started by: cassy
11 Replies
Login or Register to Ask a Question