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.

Ignoring feedback on ftp-ing..

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
Devilion
Voice
Posts: 7
Joined: Wed May 04, 2005 8:38 am

Ignoring feedback on ftp-ing..

Post by Devilion »

Hi, I've edited myself a little script that upload a file to another server of mine using ncftp (another linux ftp client, because I don't have access to the normal ftp)..

My problem is that, when the script is executed, I always get this error:
(22:52:59) (dless) [22:54] Tcl error [affv_dcctrig]: /home/albert/dless/index.html:
(22:52:59) (dless) .../dless/index.html: ETA: 0:00 15.44/ 15.44 kB 56.25 MB/s
(22:52:59) (dless) .../dless/index.html: ETA: 0:00 15.44/ 15.44 kB 531.45 kB/s

Whilst that is not an error, it is the response to the uploading commands of ncftp, so, it works, and it uploads the file, but the script breaks off right then and there, because of the error.

How do I tell the bot to ignore this text, and not see it as an error?

This is the code:

Code: Select all

proc affv_dcctrig {handle ipx arg} {
  global affvpath affvconfig affvchan
  global affv_localdir affv_useftp affv_url
  putlog "affv: Please wait..."
  exec $affvpath -co $affvconfig
  foreach affvc [string tolower $affvchan] {
    set affv_filename "$affvnew.html"
    set affv_newurl "$affv_url/$affv_filename"
    if {$affv_useftp == 1} {
	  set affv_localfile "$affv_localdir/$affv_filename"
      affv_sendftp $affv_localfile
      puthelp "PRIVMSG #channel : $affv_url"
	  return 0
    }
  puthelp "PRIVMSG #channel : $affv_url"
  }
}
which triggers:

Code: Select all

proc affv_sendftp { localfile } {
 global pingcheck  
 global affv_url
  set pipe [open "|ncftp -u username -p password ftp.omgno.com" w]
  #puts $pipe "binary" -- not needed
  puts $pipe "put -f $localfile"
  #puts $pipe "quit" -- not needed
  close $pipe
  puthelp "PRIVMSG #channel : $affv_url"
  return 0
}
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

enclose it in a catch function:
http://www.tcl.tk/man/tcl8.4/TclCmd/catch.htm
Evaluate script and trap exceptional returns
eg:

catch {set pipe [open "|ncftp -u username -p password ftp.omgno.com" w]
puts $pipe "put -f $localfile"
close $pipe
puthelp "PRIVMSG #channel : $affv_url"} error
return 0

Something like that.
User avatar
Devilion
Voice
Posts: 7
Joined: Wed May 04, 2005 8:38 am

Post by Devilion »

Thank you!

I've been searching for a function like that, but I just couldn't find it.... but it works!

Thanks a lot :)
Post Reply