| View previous topic :: View next topic |
| Author |
Message |
M4ST3R26 Voice
Joined: 17 Jun 2006 Posts: 4
|
Posted: Sat Jun 17, 2006 3:04 pm Post subject: test if FTP is online ... |
|
|
Hi guys, im new in tcl coding and i need help ... and my english suck so plz be patient
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: |
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 ! |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sat Jun 17, 2006 10:38 pm Post subject: |
|
|
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] tag when posting logs, code |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Mon Jun 19, 2006 1:40 am Post subject: |
|
|
I have a script that checks simply by attempting to connect.
Perhaps this can help you:
| Code: | 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 |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Mon Jun 19, 2006 2:27 am Post subject: |
|
|
I had posted an older version, this is what I currently use (thought something didn't look right...):
| Code: | 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. |
|
| Back to top |
|
 |
M4ST3R26 Voice
Joined: 17 Jun 2006 Posts: 4
|
Posted: Tue Jun 20, 2006 9:28 pm Post subject: |
|
|
Thx guys  |
|
| Back to top |
|
 |
starpossen Op
Joined: 10 Jan 2006 Posts: 139
|
Posted: Thu Aug 03, 2006 1:37 pm Post subject: |
|
|
Hi, I made a post asking almost the same, didnt see this one, but thanks for the link DragnLord.
Now my original question was:
| Quote: |
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? |
|
| Back to top |
|
 |
|