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.

reading command from an ftp site

Old posts that have not been replied to for several years.
Locked
T
TurboChicken
Halfop
Posts: 61
Joined: Wed Sep 29, 2004 3:18 pm

reading command from an ftp site

Post by TurboChicken »

need to make a script that will login into an ftp and run a command and return the reply... which i am then going to parse and put into a mysqldb...

i've found this script on the forum and to test i am trying to make it just display the ftp reply in a channel... unfortunately it doesn't seem to be working.

Code: Select all

bind pub -|- !monty ftpcheck
proc ftpcheck {n u h t a} {
  putserv "PRIVMSG #turbo-test :users working"
  set host "ip of site"
  set port "port of site"
  set user "user"
  set pass "pass"
  catch {socket $host $port} sock
  if {[string match -nocase "sock?" $sock]} {
    puts $sock "USER $user"
    puts $sock "PASS $pass"
    puts $sock "site monthdn 3"
    set i 0
    while {![eof $sock]} {
      flush $sock
      gets $sock line
      if {[string match -nocase 200 [lindex $line 0]]} {
        putserv "#Turbo-test $line"
      }
      if $i==100 { close $sock }
      incr i 1
    }
  } else {
    putserv "PRIVMSG #Turbo-test :Error No Route Host."
    return 0
  }
}
the first privmsg to turbo-test works but nothing else
** EDIT ** i get the no route to host reply now so something wrong with the socket syntax?

i've logged into the ftp manually from the shell and it works... the reply to site monthdn 3 looks a lil like this

Code: Select all

200-     __  _______  _   __________  ______  ____ _       ___   __
200-    /  |/  / __ \/ | / /_  __/ / / / __ \/ __ \ |     / / | / /
200-   / /|_/ / / / /  |/ / / / / /_/ / / / / / / / | /| / /  |/ /
200-  / /  / / /_/ / /|  / / / / __  / /_/ / /_/ /| |/ |/ / /|  /
200- /_/  /_/\____/_/ |_/ /_/ /_/ /_/_____/\____/ |__/|__/_/ |_/
200-
200-   ## User         Tagline                  Files   Amount     Speed
200- [ 1] user1        no tagline                6395     242.6GB    - k/s
200- [ 2] user2          no tagline                5908     221.1GB  7.4GB/s
200- [ 3] user3        no tagline                4167     198.8GB    - k/s
200
now i don't understand alot of the code but i understand enough to think that it should work as it is.... any ideas?

regards
Turbo
Locked