AutoHotkey Community

It is currently May 27th, 2012, 1:42 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: FTP Upload
PostPosted: June 22nd, 2008, 7:55 pm 
Offline

Joined: June 22nd, 2008, 7:47 pm
Posts: 3
Hi,

I know there are many threads about ftp here, but i spend a lot of time trying to connect and succesfully upload a file to my ftp, but it still don't work out. Can anybody please help me and write me here a code, just to connect and upload? I tried a code from autohotkey helpfile,

Code:
FTPCommandFile = %A_ScriptDir%\FTPCommands.txt
FTPLogFile = %A_ScriptDir%\FTPLog.txt
FileDelete %FTPCommandFile%  ; In case previous run was terminated prematurely.

FileAppend,
(
open host.domain.com
username
password
binary
put %VarContainingNameOfTargetFile%
quit
), %FTPCommandFile%

RunWait %comspec% /c ftp.exe -s:"%FTPCommandFile%" >"%FTPLogFile%"
FileDelete %FTPCommandFile%  ; Delete for security reasons.
Run %FTPLogFile%  ; Display the log for review.


but it didn't work, it uploaded empty file to the ftp and do nothing...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 22nd, 2008, 8:58 pm 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
You need:
Code:
FileSelectFile, VarContainingNameOfTargetFile

at the beginning. it will prompt for the file to upload

_________________
Image
ʞɔпɟ əɥʇ ʇɐɥʍ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 23rd, 2008, 2:30 pm 
Offline

Joined: June 22nd, 2008, 7:47 pm
Posts: 3
I did this:
Code:
FTPCommandFile = %A_ScriptDir%\FTPCommands.txt
FTPLogFile = %A_ScriptDir%\FTPLog.txt
FileDelete %FTPCommandFile% 

FileAppend,
(
open xxx
xxx
xxx
binary
put ach.txt
quit
), %FTPCommandFile%

RunWait %comspec% /c ftp.exe -s:"%FTPCommandFile%" >"%FTPLogFile%"
FileDelete %FTPCommandFile%
Run %FTPLogFile%

and in log is:
Code:
...
...
230 User xxx logged in
ftp> binary
200 Type set to I
ftp> put ach.txt
200 PORT command successful
ftp>

file ach.txt is uploaded, but it has 0 bites. I had to kill that process, because it did nothing, for a long time (ach.txt contains few chars). I am not an idiot, but I am confused about that...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 6th, 2008, 10:58 pm 
Offline

Joined: June 12th, 2008, 4:14 am
Posts: 8
It may sound stupid... but a similar thing happened to me... try putting quotes around the file you want to put....

Code:
FTPCommandFile = %A_ScriptDir%\FTPCommands.txt
FTPLogFile = %A_ScriptDir%\FTPLog.txt
FileDelete %FTPCommandFile%  ; In case previous run was terminated prematurely.

FileAppend,
(
open host.domain.com
username
password
binary
put "%VarContainingNameOfTargetFile%"
quit
), %FTPCommandFile%

RunWait %comspec% /c ftp.exe -s:"%FTPCommandFile%" >"%FTPLogFile%"
FileDelete %FTPCommandFile%  ; Delete for security reasons.
Run %FTPLogFile%  ; Display the log for review.


notice the quotes on here

put "%VarContainingNameOfTargetFile%"

also.... you did your variable wrong... you need to define the file first... below is a version of the CORRECT code... trust me, it will work.

Code:
FTPCommandFile = %A_ScriptDir%\FTPCommands.txt
FTPLogFile = %A_ScriptDir%\FTPLog.txt
FileDelete %FTPCommandFile%  ; In case previous run was terminated prematurely.
fileselectfile, file
FileAppend,
(
open host.domain.com
username
password
binary
put "%file%"
quit
), %FTPCommandFile%

RunWait %comspec% /c ftp.exe -s:"%FTPCommandFile%" >"%FTPLogFile%"
FileDelete %FTPCommandFile%  ; Delete for security reasons.
Run %FTPLogFile%  ; Display the log for review.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: It works!
PostPosted: December 31st, 2009, 3:06 am 
Nice and simple... your FTP code works like a charm. Found you looking for just this.
Thanks for your post,
Bizibill


Report this post
Top
  
Reply with quote  
PostPosted: January 17th, 2010, 3:49 am 
Offline

Joined: May 31st, 2007, 2:42 pm
Posts: 3
Location: Vicksburg, MS
How would the script look for an anonymous login?

_________________
Chuck Miller


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: bobbysoon, Google Feedfetcher, JSLover, Tipsy3000 and 17 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group