Page 1 of 1 1
Topic Options
#208535 - 2014-02-06 07:52 PM noob help on ftp service please
Buhli Offline
Fresh Scripter

Registered: 2012-09-24
Posts: 28
Loc: Berlin, Germany
Hello gents,

i need some help of you guys again.

When i tried out some examples, i found at the forums, i was really confused and they didn't work for me. The challenge i have is to make an automated ftp Login, if there are files-copy them to a local dir and remove them from the ftp-Server.

On the ftp-Server are no sub-directories, just the main directory with a couple of XML-files.

my thinking was:
$Server = "ftp://blabla.com"
$User = "Dummy"
$Pass = "DummyPass"
$Source ="ftp://blabla.com\*.xml"
$Target = "C:\TargetDir\*.xml"

Sorry about my fooling, but i don't understand all the stuff in the FTPget-function.
I'm pretty sure i did something wrong, but what? Maybe i also should use a variable $ file, not sure. I am the Hardware guy in my Company, not a prgrammer.

Can someone help me with this please?

For you guys it's maybe not a big deal, but for me it is.

The OS where it should run is Win XP - is there any different on other Windows btw?

Thank you very much for listen me and i hope, i posted this in the correct forums,

Buhli

Top
#208536 - 2014-02-06 08:12 PM Re: noob help on ftp service please [Re: Buhli]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
The immediate challenge with ftpGet() is that it returns a single file. The FTP command syntax is "get" for a single file or "mget" for wildcard returns.

You might want to try and change the following
 Code:
  if $sUser
    $oFTP.Open("GET", $sURL, not 1, $sUser, $sPass)
  else
    $oFTP.Open("GET", $sURL, not 1)
  endif
to put an "M" in front of each "GET". The result will be to pull down all of the XML files.

Unless there's a mechanism to later remove the files from the FTP server, you'll keep pulling the same files over and over again, along with any new ones.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#208537 - 2014-02-06 09:05 PM Re: noob help on ftp service please [Re: Glenn Barnas]
Buhli Offline
Fresh Scripter

Registered: 2012-09-24
Posts: 28
Loc: Berlin, Germany
Thank you very much Glenn, i will try that tomorrow!
But i guess, i'm a hopeless case at this kind of work.

Why is there an "s" infront of the variables?

Cheers,

Buhli

Top
#208539 - 2014-02-06 11:25 PM Re: noob help on ftp service please [Re: Buhli]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Google "Hungarian Notation" \:\)

Basically, the first 1 or 3 chars are used to identify the type of data that a variable will usually contain.

I tend to take liberties with my ancestry ;\) - I only use an "a" to differentiate between arrays and simple vars in most cases, although I do use an "o" to reference COM Objects.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#208540 - 2014-02-07 03:55 AM Re: noob help on ftp service please [Re: Glenn Barnas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
being lazy and not opening the UDF, but IIRC, it uses xmlhttp or something similar and then the only supported commands are along the lines of HEAD (don't remember what this one really was called), PUT and GET.
_________________________
!

download KiXnet

Top
#208545 - 2014-02-07 01:18 PM Re: noob help on ftp service please [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
You've got a good memory for a lazy Basta! \:D It indeed uses XMLHTTP.

Buhli - you might look into scripting the FTP command sequence with an FTP command file to accomplish the multi-file transfer if the MGET indeed doesn't work..

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#208567 - 2014-02-10 01:55 PM Re: noob help on ftp service please [Re: Glenn Barnas]
Buhli Offline
Fresh Scripter

Registered: 2012-09-24
Posts: 28
Loc: Berlin, Germany
Hi gents,

mget don't work???

I see one more problem and i have no clue how to fix this.
Not tried right now, just planning.

If it would work with mget and then with mdelete all the files, it is quite dangerous imo-maybe there comes another file between the commands. I guess it will be removed as well?!

Btw, you guys really make me think about scripting;)

Cheers,

Buhli

Top
#208584 - 2014-02-12 09:01 AM Re: noob help on ftp service please [Re: Buhli]
Buhli Offline
Fresh Scripter

Registered: 2012-09-24
Posts: 28
Loc: Berlin, Germany
Is there an option to get and remove them one by one?
That would be great, but i have no idea it is possible or not to make a loop in the ftp block.
I don't want to reconnect all the time, but if it is nesscary...

Buhli

Top
#208585 - 2014-02-12 01:19 PM Re: noob help on ftp service please [Re: Buhli]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ftpget() is just a get.

if you want to actually manage the other end, this is not the way to go.

instead you should be looking to a real ftp client.
http://support.microsoft.com/kb/96269
_________________________
!

download KiXnet

Top
#208586 - 2014-02-12 03:30 PM Re: noob help on ftp service please [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
Use Shell to call a script like Lonk referenced to do an LS command to a file.

Next, open and enumerate the file from kix. You can use ftpget() to get the files.

After each get, use a batch file to RM the file from the server.

This way, you get all the files, and delete all the files you processed. You won't get or delete any file that arrives during your script processing.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

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
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.063 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

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