how can i check to see if a ftp is online, on port 21?
Umm well I guess you'd learn the FTP protocol and see if when you connect to port 21 you get a valid FTP response.
yeah, but i was wondering if someone could help me that already knew it
Well the first (and easiest) step would be try and make sure sockopen suceeds on port 21, if it doesn't then you know there isn't an ftp server. Next thing you want to check for is probably going to be a 220 reply. The 220 reply looks like:
220 some-text-here
The text can be anything, so just check for the 220. In some circumstances, the server might be busy and to tell you this it will send a 120 reply. Again, you should only ensure that the first word is 120, the text after it will vary. Lastly, it may reply with a 421. This indicates it is an ftp server, but it doesn't want to let you connect. It is possible that other messages might be sent, but those are the standard ones that you should expect.
ok i did this:
alias cftp {
if ($1 != $null) {
sockopen ftp $1 21
}
}
on *:SOCKREAD:ftp:{
/sockread %temp
/write ftp.txt %temp
}
on *:SOCKOPEN:ftp:{
sockwrite -n $sockname GET / HTTP/1.1
sockwrite -n $sockname Host: mtec89.ath.cx
sockwrite -n $sockname Connection: keep-alive
sockwrite $sockname $crlf
}
and got this:
220 MTec FTP
500 Unknown command.
500 Unknown command.
500 Unknown command.
so it knows it's online right? now how do i just make it check to see if its online, and do a command if its onlines, and if not, do nothing
Why are you sending HTTP commands to FTP server, those are two diffrent protocols?
because i dont know anything about sockets, thats why im trying to get help..
can someone please help me with this?
How about reading the RFC about FTP. Or is that again too hard a task for you, and looking for qwerty to spell it out for you again
Another chap that uses this web board.
qwertyI just realised something too, it would be very hard to mis-spell his name.
You have no idea of the stupidity of some internet users then
Over 10% would misspell it on the first attempt
lol.
*Watchdog slaps his jowls.
You shouldn't have to send anything to the server, it should send you the 220 when you connect.
eh...this is too difficult...i have other projects to get done to worry about this...
thanks for ur time ;p
it's not that difficult..
alias cftp { sockopen ftp $$1 $iif($2,$2,21) | .timerWaitForFTP 1 5 echo -s FTP on $$1 is not responding or does not exist }
on *:sockread:ftp:{
var %temp | sockread %temp
if ($gettok(%temp,1,32) == 220) echo -s FTP on $sock($sockname).ip is online and serving
if ($gettok(%temp,1,32) == 120) echo -s FTP on $sock($sockname).ip is online but busy
if ($gettok(%temp,1,32) == 421) echo -s FTP on $sock($sockname).ip is online but not willing to serve
unset %waitForFTP | sockclose ftp | .timerWaitForFTP off
}