#152626 - 2005-12-01 11:55 AM
Problems FTPget
|
fujimoori
Fresh Scripter
Registered: 2005-11-08
Posts: 8
Loc: Berlin, Germany
|
Hello everybody! I feel a bit stupid about my question because I didnīt understand all the $ @ etc. in the script. So two questions: Where I can learn about the very basicīs like paraterdefinitions syntax etc...? Second: Why do I get "error in parameterdefinition of ftpget" when I use this code:
;-------Start--------- Function FTPget("ftp.sonnenwaermeag.de/test.txt","c:\daten","user","password") Dim $oFTP, $oStream $sUser=""+$sUser $oFTP = CreateObject("Microsoft.XMLHTTP") if @error $ftpget=1 exit 1 endif $oStream = CreateObject("ADODB.Stream") if @error $ftpget=2 exit 2 endif if $sUser $oFTP.Open("GET", $sURL, not 1, $sUser, $sPass) else $oFTP.Open("GET", $sURL, not 1) endif if @error $ftpget=3 exit 3 endif $oFTP.Send $oStream.Type = 1 $oStream.Mode = 3 $oStream.open $oStream.Write($oFTP.responseBody) if @error $ftpget=4 exit 4 endif $oStream.SaveToFile($sTargetFile, 2) if @error $ftpget=5 exit 5 endif $oStream.Close EndFunction ;-------Stop----------
Thank You!
|
|
Top
|
|
|
|
#152627 - 2005-12-01 12:05 PM
Re: Problems FTPget
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
You should treat the udf as a black box and not changing anything.
here a sample of how to use it in a script :
Code:
break on
$err = FTPget("ftp.sonnenwaermeag.de/test.txt","c:\daten","user","password")
if not $err "File downloaded.." ? else "Download Error: " + $err ? endif
? "Hit a key ..." get $
exit 0
; udf --- do not change below
Function FTPget($sURL, $sTargetFile, optional $sUser, optional $sPass) Dim $oFTP, $oStream $sUser=""+$sUser $oFTP = CreateObject("Microsoft.XMLHTTP") if @error $ftpget=1 exit 1 endif $oStream = CreateObject("ADODB.Stream") if @error $ftpget=2 exit 2 endif if $sUser $oFTP.Open("GET", $sURL, not 1, $sUser, $sPass) else $oFTP.Open("GET", $sURL, not 1) endif if @error $ftpget=3 exit 3 endif $oFTP.Send $oStream.Type = 1 $oStream.Mode = 3 $oStream.open $oStream.Write($oFTP.responseBody) if @error $ftpget=4 exit 4 endif $oStream.SaveToFile($sTargetFile, 2) if @error $ftpget=5 exit 5 endif $oStream.Close EndFunction
more info on this topic : How to use udfs
Edited by Jochen (2005-12-01 12:07 PM)
_________________________
|
|
Top
|
|
|
|
#152629 - 2005-12-01 01:18 PM
Re: Problems FTPget
|
fujimoori
Fresh Scripter
Registered: 2005-11-08
Posts: 8
Loc: Berlin, Germany
|
Thank You so far! Thera are remaining Problems: I get error Nr 4, what does it mean? There is already a discussuin about error4 but i didnīt suceed with this. Maybe it helps to sy that Iīm running windows 2000 professional with office 2000.I used:
break on
$err = FTPget("ftp://ftp.sonnenwaermeag.de/test.txt","c:\ten","user","pw")
if not $err "File downloaded.." ? else "Download Error: " + $err ? endif
? "Hit a key ..." get $
exit 0
and the unchanged UDF
|
|
Top
|
|
|
|
#152631 - 2005-12-01 01:53 PM
Re: Problems FTPget
|
fujimoori
Fresh Scripter
Registered: 2005-11-08
Posts: 8
Loc: Berlin, Germany
|
OK I changed the server where I get the data from because FileZilla had problems too with getting the file list. The other server seems responding correctly but now I get Error 5. I tried to save the file to usb-stick to different places on the harddisc, I deaktivated my Kaspersky but all failed...
|
|
Top
|
|
|
|
#152633 - 2005-12-01 02:05 PM
Re: Problems FTPget
|
fujimoori
Fresh Scripter
Registered: 2005-11-08
Posts: 8
Loc: Berlin, Germany
|
Thanks very much Mart!
|
|
Top
|
|
|
|
#152635 - 2005-12-01 02:53 PM
Re: Problems FTPget
|
fujimoori
Fresh Scripter
Registered: 2005-11-08
Posts: 8
Loc: Berlin, Germany
|
Yes! I dont get the right files but in general it works! Thanks again!
|
|
Top
|
|
|
|
#152637 - 2005-12-04 10:55 PM
Re: Problems FTPget
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
There was a UDF that Jooel created when we were researching FTPput/FTPget that we were only able to get rolling with get.
Kent
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 871 anonymous users online.
|
|
|