Page 1 of 1 1
Topic Options
#152626 - 2005-12-01 11:55 AM Problems FTPget
fujimoori Offline
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 Administrator Offline
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
#152628 - 2005-12-01 12:10 PM Re: Problems FTPget
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
First off all you should not modify UDF's. They are code ready for use. The proper way to use them is documented in the commented section of the UDF and in the FAQ.
FTP get can be used like this.

Code:

FTPget("site and file to get should be here","path to store the file should go here")



Off course you should also paste the UNCHANGED FTPGet() udf code in the script. FTPGet() can be found here FTPget() - download a file.

About the @ and $ characters.
All macro's have @ as the first character. They are filled by kix when it starts to run. No user interference needed.
The $ marks a variable. It can be anything. $1234567890 or $abcdefg it's all valid but just $ is also valid. All is documented in the manual included in each download.


Edited by Mart (2005-12-01 12:12 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#152629 - 2005-12-01 01:18 PM Re: Problems FTPget
fujimoori Offline
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
#152630 - 2005-12-01 01:23 PM Re: Problems FTPget
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
4: The system cannot open the file.
Are you sure you got the path and filename correct? Or a privileges issue.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#152631 - 2005-12-01 01:53 PM Re: Problems FTPget
fujimoori Offline
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
#152632 - 2005-12-01 01:56 PM Re: Problems FTPget
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Error 5: Access is denied.
Looks like some kind of privileges issue.

MS error codes page.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#152633 - 2005-12-01 02:05 PM Re: Problems FTPget
fujimoori Offline
Fresh Scripter

Registered: 2005-11-08
Posts: 8
Loc: Berlin, Germany
Thanks very much Mart!
Top
#152634 - 2005-12-01 02:12 PM Re: Problems FTPget
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Got it working?
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#152635 - 2005-12-01 02:53 PM Re: Problems FTPget
fujimoori Offline
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
#152636 - 2005-12-03 06:59 PM Re: Problems FTPget
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You might also want to read the KiXtart Manual, it even contains a link to a list of error codes and their meanings.
_________________________
There are two types of vessels, submarines and targets.

Top
#152637 - 2005-12-04 10:55 PM Re: Problems FTPget
Kdyer Offline
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
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#152638 - 2005-12-05 12:42 AM Re: Problems FTPget
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
kent, if you read upwards, this whole trhead is about that udf and howto use udfs in the first place.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 871 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.062 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org