This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

test if FTP is online ...

Help for those learning Tcl or writing their own scripts.
Post Reply
M
M4ST3R26
Voice
Posts: 4
Joined: Sat Jun 17, 2006 2:55 pm

test if FTP is online ...

Post by M4ST3R26 »

Hi guys, im new in tcl coding and i need help ... and my english suck so plz be patient :D

I want my eggdrop to connect on FTP and check if the FTP is UP and running, if the user/password is correct. This part is done but i want to catch connection details because my code always say Yes the ftp is up even if the login/pass isnt good .....

there's my code ...


Code: Select all

proc check_pub {nick uhost hand chan arg} {
	global check_pass check_chan
	if {$arg !=""} {
	set check_strip [string map { "ftp://" "" ":" " " "@" " "} $arg]
		set check_FTP $arg
		set check_address [lindex $check_strip 2]
		set check_port [lindex $check_strip 3]
		set check_username [lindex $check_strip 0]
		set check_password [lindex $check_strip 1]
		putlog "$check_FTP -- $check_username -- $check_password -- $check_address -- $check_port --"
		putserv "PRIVMSG $check_chan :\002\00309$nick\002\003, verrification du FTP (\002\00304 $check_address \002\003) un instant svp ..."
		set pipe [open "|/usr/bin/ftp -n $check_address $check_port" w]
		putserv "PRIVMSG $check_chan :Connection à $check_address en cours ...."
		puts $pipe "user $check_username $check_password"
		puts $pipe "put /home/m4st3r26/test.txt /test.txt"
		puts $pipe "quit"
		putserv "PRIVMSG $check_chan :Connection Reussi!"
		close $pipe
		return 1
	}
}

Thanks alot !
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

you need to also read the pipe to see the actual ftp server response

this is best done asynchronously using [fileevent], search the forum for "tail -f" script sample
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

I have a script that checks simply by attempting to connect.
Perhaps this can help you:

Code: Select all

bind pub o !ftptest ftp:test
proc ftp:test {n u h c a} {
 if {[catch {set ftp_test [socket -async $a 21]} sockerr]} {
   putserv "privmsg $n :$a is Down"
   } else {
   putserv "privmsg $n :$a is Up"
 }
 close $ftp_test
}
Edit: this should give you an idea of possible ways to do this, not an absolute answer
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

I had posted an older version, this is what I currently use (thought something didn't look right...):

Code: Select all

bind pub o !ftptest ftp:test
proc ftp:test {n u h c a} {
 if {[catch {set ftp_test [socket -async $a 21]} sockerr]} {
   putserv "privmsg $c :$a reports: $sockerr"
   } else {
   putserv "privmsg $c :$a reports: [gets $ftp_test]"
 }
 close $ftp_test
}
putlog "FTP Test loaded.."
On successful connection it retuns ftpd version.
M
M4ST3R26
Voice
Posts: 4
Joined: Sat Jun 17, 2006 2:55 pm

Post by M4ST3R26 »

Thx guys ;)
s
starpossen
Op
Posts: 139
Joined: Tue Jan 10, 2006 1:08 am

Post by starpossen »

Hi, I made a post asking almost the same, didnt see this one, but thanks for the link DragnLord.

Now my original question was:
Hi.
I was wondering if it would be possible to make a script which would check if a site is online/up and the post the result to the channel eg:

Site is down then the bot would announce in a channel that it was down and keep doing so with intervals

Site is up then the bot would announce it but only once.

I don't know if I explained this good enough, I hope so.
How would I go about doing this with your script DragnLord?
Post Reply