#185846 - 2008-02-29 09:51 PM
Using FTPPut() but a CD
|
brewdude6
Hey THIS is FUN
Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
|
I'd like to use FTPput to transfer some files, but I need to "cd" to a directory first.
Should I just create my own shell statement or can I use the UDF to do this?
;PARAMETERS : Host - The target IP Address, host or URL ; : Path - The path to the source file ; : File - The source file ; : UserID - The login ID ; : PassWD - The login ID's password ; : optional FTPcommand - an additional FTP command that you ; want to add (e.g. rename)
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs. -Mark Twain
|
Top
|
|
|
|
#185850 - 2008-02-29 10:47 PM
Re: Using FTPPut() but a CD
[Re: brewdude6]
|
Glenn Barnas
KiX Supporter
Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
|
It won't work unless you modify the UDF slightly.
Change the function declaration to:
Function FTPput($Host, $Path, $File, $UID, $PWD, optional $FTPcmds1, optional $FTPcmds2) Then change the commands to write the FTP command file, as such:
; Create an FTP command file
If Open(1,$FTPchk+"\FTPcmds",5) = 0
WriteLine(1,$UID+@CRLF)
WriteLine(1,$PWD+@CRLF)
WriteLine(1,"binary"+@CRLF)
WriteLine(1,"lcd "+$Path+@CRLF)
; Additional FTP commands passed to the function are actioned here
WriteLine(1,""+$FTPcmds1+@CRLF)
; write the data put command
WriteLine(1,"mput "+$File+@CRLF)
; Now get the transferred file back to a check area so we can confirm it worked
WriteLine(1,"lcd "+$FTPchk+@CRLF)
WriteLine(1,"mget "+$File+@CRLF)
; Additional FTP commands passed to the function are actioned here
WriteLine(1,""+$FTPcmds2+@CRLF)
WriteLine(1,"close"+@CRLF)
WriteLine(1,"quit"+@CRLF)
Close(1)
EndIf
This is untested, but similar to things I've done in the past.
Realize that you now have two optional args - one to execute before the put and one to execute after. If you need to perform more than one command before or after, you'll need to build a string with the individual FTP commands separated by @CRLF - like "CMD1" + @CRLF + "CMD2..."
Glenn
_________________________
Actually I am a Rocket Scientist!
|
Top
|
|
|
|
#185852 - 2008-03-01 12:22 AM
Re: Using FTPPut() but a CD
[Re: brewdude6]
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
Or you may want to consider getting Wget
Wget on Wikipedia
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 557 anonymous users online.
|
|
|