|
|
|||||||
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? Quote: ;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) |
||||||||
|
|
|||||||
According to the documentation you would add the "optional" command as the last parameter of the UDF Code: FTPPut("c:\temp\","myfile.txt","Anonymous","someone@somewhere.com","cd subdirectory") |
||||||||
|
|
|||||||
I can "cd", but that puts the command "after" the file has already been attempted to "put". |
||||||||
|
|
|||||||
It won't work unless you modify the UDF slightly. Change the function declaration to: Code: Function FTPput($Host, $Path, $File, $UID, $PWD, optional $FTPcmds1, optional $FTPcmds2) Then change the commands to write the FTP command file, as such: Code: ; 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 |
||||||||
|
|
|||||||
Or you may want to consider getting Wget Wget on Wikipedia |