egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

test if FTP is online ...

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
M4ST3R26
Voice


Joined: 17 Jun 2006
Posts: 4

PostPosted: Sat Jun 17, 2006 3:04 pm    Post subject: test if FTP is online ... Reply with quote

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

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
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sat Jun 17, 2006 10:38 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Mon Jun 19, 2006 1:40 am    Post subject: Reply with quote

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
View user's profile Send private message
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Mon Jun 19, 2006 2:27 am    Post subject: Reply with quote

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
View user's profile Send private message
M4ST3R26
Voice


Joined: 17 Jun 2006
Posts: 4

PostPosted: Tue Jun 20, 2006 9:28 pm    Post subject: Reply with quote

Thx guys Wink
Back to top
View user's profile Send private message
starpossen
Op


Joined: 10 Jan 2006
Posts: 139

PostPosted: Thu Aug 03, 2006 1:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber