Sivakatirswami a �crit :
> 
> Thanks to Andu's help, we have worked out a simple script based on his FTP
> stack that sends a single file, using passive FTP to your web site.
> 
> Hopefully others will find this useful. Note I have no error trapping or
> socketTimeout handlers. . .so if you hang, it means you are stuck in a
> repeat block, Just hold your command period down till the repeat quits. If
> someone can figure out how and where to set those go please post and
> "upgrade" to this list. Thanks! note, this assume you have a log field on
> the card that is running the script. Note we are on a T1 line and perhaps
> the socketTimeOutinterval needs to be more for a dial up connection. . .but
> I don't even understand that part of it yet. . .anyway this does work.  If
> anyone can improve on this (and Scott probably could. . .) please do and
> post an update for all of us. This is a first draft by a complete socket
> newBie. I didn't even read the RFC docs yet. . .
> 
> ==========
> 
> ##you must set all variables for the ftp address, user name, password
> ##etc. You will do a passive transfer (server asigns the port and tells
> ##you on which port to write the data. You will have to read from socket
> ##Q every time you write to it; the server answers to all requests and
> ##you want them all to know the status and keep the socket clear. Again,
> ##check all variables since some of them need to be declared at the top.
> 
> global Q, iName,IPath,fData,nData, tIP
> 
> on startFtp
>   ## First initialize variables with your web site host address
>   ## username and password, These could be passed as globals from some other
>   ## window or handler where the data could be permanently stored or
> changed.
>   set the socketTimeOutInterval to 5000
>   put hostnametoaddress(www.YourWebSite.com) into remoteAddress
>   put "UserName" into username
>   put "passWord" into password
> 
>   put empty into fld "log"
>   put  remoteAddress &":21" into Q
>   open socket to Q
>   write "USER " & username & CRLF to socket Q
>   read from socket Q for 1 line
>   if char 1 of it is "5" or word 1 of it is "421" then #error
>     answer it
>     exit "startFtp"
>   else
>     write "PASS " & password & CRLF to socket Q
>     repeat 100 times
>       read from socket Q for 1 line
>       put it &cr after fld "log"
>       if char 1 of it is "5" then
>         answer it
>         exit "startFtp"
>       end if
>       if char 4 of it is not "-" then exit repeat
>       ##if login is OK you
>       ##want to read all Welcome stuff and discard it
>     end repeat
>     sendFile
>   end if
> 
> end startFTP
> 
> on sendFile
>   set the directory to "/MyHardDrive"
>   put URL "binfile:BIG-om-animation -1.gif" into fData
>   put "public_html/BIG-om-animation-1.gif" into iPath
>       ## obviously you could pass the file references for fData and iPath
>       ## from another control/fields as globals
>   put the length of fData into tBytes
>   put tBytes & cr  after fld "log"
>   write "PASV"  & CRLF to socket Q
>   repeat 20 times
>     read from socket Q for 1 line
>     put cr & it after fld "log"
>     if it contains "Entering Passive Mode" then exit repeat
>   end repeat
> 
>   put it into tReply
>   replace ")" with empty in tReply
>   set the itemDel to "("
>   put item 2 of tReply  into n1
>   set itemDel to ","
>   put item 1 to 4 of n1 into tIP
>   replace "," with "." in tIP
> 
>   put (item -2 of n1)*256  into a1
>   put item  -1 of n1 into a2
>   put a1+a2  into tPort
>   put tIP & ":" & tPort into tIP
>   open socket tIP
>   put cr &  tIP after fld "log"
>   write "TYPE "& I & CRLF to socket Q
>   read from socket Q for 1 line
>   put  cr & it after fld "log"
>   write  "STOR " & IPath & CRLF to socket Q
>   read from socket Q for 1 line
>   put  cr & it after fld "log"
>   set cursor to busy
>   senddata
> end sendFile
> 
> on senddata
>   put char 1 to 5000 of fData into nData
>   write nData to  socket  tIP with  message "writemore"
> end senddata
> 
> on writemore
>   delete char 1 to 5000 of fData
>   put "delete 5000"
>   put the length of fData into sLength
>   put sLength
>   if fData is not empty then
>     if sLength>=5000 then
>       put char 1 to 5000 of fData into nData
>       write nData to  socket  tIP  with message "writemore"
>       put "OK"
>     else
>       put fData into nData
>       write nData to  socket  tIP  with message "writemore"
>       put "OK"
>     end if
>   else
>     Put "Closing"
>     close socket tIP
>     read from socket Q for 1 line #for confirmation
>     put  cr & it after fld "log"
>     write "QUIT" & crlf to socket Q
>     read from socket Q for 1 line #for confirmation
>     put  cr & it after fld "log"
>     close socket Q
>     beep
>   end if
> end writemore
> 
> the following was the first feeble attempt at setting up a trap
> for socketTimeOut, but I haven't figured out how to implement it yet.
> 
> --on socketTimeOut Q
>  -- put "true" into tSocketIsClear
> --end socketTimeOut Q
> 
> Hinduism Today
> 
> Sivakatirswami
> Editor's Assistant/Production Manager
> www.HinduismToday.com
> www.HimalayanAcademy.com
> [EMAIL PROTECTED]
> 
> Archives: http://www.mail-archive.com/[email protected]/
> Info: http://www.xworlds.com/metacard/mailinglist.htm
> Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Great scripts !

After testing, <set the socketTimeoutInterval to "10"> run fine for me on both
Linux and WinNT4. I let the on socketTimeOut handler empty even if it's,
perhaps, not the best to do, Scott ?
<on socketTimeOut>
<end socketTimeOut>

Kind Regards, Pierre Sahores

chef de projet cyberlibrairie
SNPIN - CNDP. 91, rue Gabriel-Peri
92120 Montrouge. T�l.: 01.64.45.05.33

Penser la part du r�ve et
produire l'avantage comp�titif.

Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to