AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FTP Upload

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
milos.kopecky



Joined: 22 Jun 2008
Posts: 3

PostPosted: Sun Jun 22, 2008 6:55 pm    Post subject: FTP Upload Reply with quote

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...
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1381
Location: USA

PostPosted: Sun Jun 22, 2008 7:58 pm    Post subject: Reply with quote

You need:
Code:
FileSelectFile, VarContainingNameOfTargetFile

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

ʞɔпɟ əɥʇ ʇɐɥʍ
Back to top
View user's profile Send private message
milos.kopecky



Joined: 22 Jun 2008
Posts: 3

PostPosted: Mon Jun 23, 2008 1:30 pm    Post subject: Reply with quote

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...
Back to top
View user's profile Send private message
eternalcold



Joined: 12 Jun 2008
Posts: 8

PostPosted: Wed Aug 06, 2008 9:58 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Bizibill
Guest





PostPosted: Thu Dec 31, 2009 2:06 am    Post subject: It works! Reply with quote

Nice and simple... your FTP code works like a charm. Found you looking for just this.
Thanks for your post,
Bizibill
Back to top
ChazMiller



Joined: 31 May 2007
Posts: 3
Location: Vicksburg, MS

PostPosted: Sun Jan 17, 2010 2:49 am    Post subject: Script for Anonymous login Reply with quote

How would the script look for an anonymous login?
_________________
Chuck Miller
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group