Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check FTP connection before transfer

Status
Not open for further replies.

normntwrk

MIS
Aug 12, 2002
336
US
Anyone know how to check to see if a FTP server is up before trying to do a transfer without using ping ? The customer server IP is not pingable. This needs to e a automated process.

I can use "telnet serverip 21" and it will tell me it is connected but it just hangs there and doesn't exit and the script hangs. I've tried calling that script from another and then they both hang.

Any ideas?
Thanks in advance

Norm
 
FTPRUN=$( tcptraceroute ftp.netbsd.org 21|grep -v "Tracing"|awk '/open/{print $4}'|sed 's/\[//g;s/\]//g' )

if [ $FTPRUN = open ]
then
RUN_YOUR_COMMANDS_HERE
else
DONT_DO_ANYTHING_FOOLISH
fi

perl -e 'print $i=pack(c5,(40*2),sqrt(7600),(unpack(c,Q)-3+1+3+3-7),oct(104),10,oct(101));'
 
Thanks for the ideas, box doesn't have nmap and these are production servers so I hate to add any software otherwise that would work fine.

I'll try the other ideas out today

Thanks guys

Norm
 
Here is the same thing running ping (standard on most machines). Will send four pings and if the machine responds four times, it will run commands else won't run em

IPFUP=$( ping -c 4 google.com|awk '/received/{print $4}' )

if [ $IFUP = 4 ]
then
RUN_YOUR_COMMANDS_HERE
else
DONT_DO_ANYTHING_FOOLISH
fi


perl -e 'print $i=pack(c5,(40*2),sqrt(7600),(unpack(c,Q)-3+1+3+3-7),oct(104),10,oct(101));'
 
gotta love it, got this trying solution #2
Trying...
Connected to 172.17.227.4.
Escape character is '^]'.
172.17.227.4: Not a typewriter
Connection closed.


# 3 not working as apparently they are blocking traceroute even when it's up

 
What about ping? Well wouldnt make a diff it the server is running but ftpd is down... tcptraceroute would help you out here though if you ask me


perl -e 'print $i=pack(c5,(40*2),sqrt(7600),(unpack(c,Q)-3+1+3+3-7),oct(104),10,oct(101));'
 
the IP address is not pingable....sending server is AIX and doesn't have tcptraceroute only traceroute

i'm getting closer..calling a script (called tel22 ..solution #2)within a script

#!/bin/ksh
/home/norm/scripts/tel22 &

TST=`ps -eaf | grep tel22 | egrep -v grep|awk '{print $2}'`

echo $TST

kill -9 $TST

echo "should be dead"

TST2=`ps -eaf | grep "telnet 172.17.227.2 21" | egrep -v grep|awk '{print $2}'`

echo $TST2

kill -9 $TST2

echo "hopefully killed connection"

read x
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top