The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to check sqlplus command is successfull or not in HP UX? plaban.rout HP-UX 5 11-20-2007 06:48 AM
Detecting a key combination mobile01 High Level Programming 11 12-22-2006 09:46 AM
Not detecting CD ROm drive sbasetty Gentoo 13 12-05-2006 11:00 AM
solaris 10 isnt detecting my internet connection stride6 SUN Solaris 5 06-22-2006 05:08 AM
check for successfull telnet session sumguy UNIX for Dummies Questions & Answers 0 05-15-2006 01:27 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-29-2005
beilstwh beilstwh is offline
Registered User
  
 

Join Date: Jul 2004
Location: New York State
Posts: 65
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 (permalink)  
Old 09-29-2005
linuxpenguin's Avatar
linuxpenguin linuxpenguin is offline Forum Advisor  
Registered User
  
 

Join Date: May 2002
Location: India
Posts: 295
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 (permalink)  
Old 09-30-2005
beilstwh beilstwh is offline
Registered User
  
 

Join Date: Jul 2004
Location: New York State
Posts: 65
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:23 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0