FTP Uploading - 11/10/03 02:52 PM
Hi..I'm trying to make a FTP script. My problem is that upload isn't working assuredly. If I upload TXT files it works good (tried with a 3mb txt file), but when I upload JPGs for example (even small ones) it doesn't work at all most of the time.
My guess is that JPGs have lots of weird chars...maybe $crlf or something and it fails to bread or something. Anyway it gives error msg like this (line is just after the bread) :
* /sockwrite: insufficient parameters (line 39, script1)
Any guesses whats wrong?
My guess is that JPGs have lots of weird chars...maybe $crlf or something and it fails to bread or something. Anyway it gives error msg like this (line is just after the bread) :
* /sockwrite: insufficient parameters (line 39, script1)
Any guesses whats wrong?
Code:
on *:sockopen:ftp:{ FTP user %user FTP pass %pass FTP TYPE I } on *:sockread:ftp:{ sockread %rdsck echo -at 9 + %rdsck if ($gettok(%rdsck,1,32) == 150) && (%intention == upload) { bread %ftp.file 1 %ftp.packetsize &ftp.data sockwrite ftp.data $bvar(&ftp.data,1,$bvar(&ftp.data,0)).text } if ($gettok(%rdsck,1,32) == 230) { ftp.list } if ($gettok(%rdsck,1,32) == 227) { set %ftp.port $calc($gettok(%rdsck,5,44) * 256 + $remove($gettok(%rdsck,6,44),$chr(41),.)) sockopen ftp.data %address %ftp.port } if (CWD command successful. isin %rdsck) ftp.list } on *:sockread:ftp.data:{ if (%intention == list) { sockread %rdsck echo -at $iif($left(%rdsck,1) == d,9D,4F) 9- $gettok(%rdsck,9-,32) --4 $bytes($gettok(%rdsck,5,32)).suf -- $gettok(%rdsck,6,32) $gettok(%rdsck,7,32) $gettok(%rdsck,8,32) } if (%intention == download) { sockread &RDSCK bwrite %ftp.file -1 -1 &rdsck } } on *:sockclose:ftp.data:{ echo -at $+ $bytes($sock(ftp.data).rcvd).suf received succesfully in $calc(($ticks - %ticks) / 1000) seconds ( $+ $round($calc(($sock(ftp.data).rcvd / 1000) / $calc(($ticks - %ticks) / 1000)),2) KB/s $+ ) } on *:SOCKWRITE:ftp.data:{ inc %å if ($sock(ftp.data).sq == 0) { bread %ftp.file $calc(%å * %ftp.packetsize) %ftp.packetsize &ftp.data echo -at $calc(%å * 925) if ($bvar(&ftp.data,0) == 0) sockclose ftp.data if ($bvar(&ftp.data,0) != 0) sockwrite ftp.data $bvar(&ftp.data,1,$bvar(&ftp.data,0)).text } } alias ftp { sockwrite -n ftp $1- echo -at 4 -- $remove($1-,%pass,(Hidden)) } alias f8 { sockclose ftp.data } alias ftp.list { set %intention list FTP PASV FTP LIST set %ticks $ticks } alias ftp.download { set %ftp.file $1- set %intention download .remove %ftp.file FTP PASV FTP RETR %ftp.file set %ticks $ticks } alias ftp.upload { set %ftp.packetsize 925 unset %ftp.size set %å 0 set %ftp.file $1- set %intention upload FTP PASV FTP STOR %ftp.file } alias FTP.start { set %address $1 set %port $2 set %user $3 set %pass $4 sockopen ftp %address %port }