Page 1 of 1 1
Topic Options
#185846 - 2008-02-29 09:51 PM Using FTPPut() but a CD
brewdude6 Offline
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?

 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)
_________________________
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
#185847 - 2008-02-29 10:03 PM Re: Using FTPPut() but a CD [Re: brewdude6]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
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")
_________________________
Today is the tomorrow you worried about yesterday.

Top
#185848 - 2008-02-29 10:10 PM Re: Using FTPPut() but a CD [Re: Gargoyle]
brewdude6 Offline
Hey THIS is FUN

Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
I can "cd", but that puts the command "after" the file has already been attempted to "put".
_________________________
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 Administrator Offline
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:
 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
_________________________
Actually I am a Rocket Scientist! \:D

Top
#185852 - 2008-03-01 12:22 AM Re: Using FTPPut() but a CD [Re: brewdude6]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Or you may want to consider getting Wget

Wget on Wikipedia

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 557 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.055 seconds in which 0.024 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