| View previous topic :: View next topic |
| Author |
Message |
milos.kopecky
Joined: 22 Jun 2008 Posts: 3
|
Posted: Sun Jun 22, 2008 6:55 pm Post subject: FTP Upload |
|
|
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 |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1381 Location: USA
|
Posted: Sun Jun 22, 2008 7:58 pm Post subject: |
|
|
You need:
| Code: | | FileSelectFile, VarContainingNameOfTargetFile |
at the beginning. it will prompt for the file to upload _________________
ʞɔпɟ əɥʇ ʇɐɥʍ |
|
| Back to top |
|
 |
milos.kopecky
Joined: 22 Jun 2008 Posts: 3
|
Posted: Mon Jun 23, 2008 1:30 pm Post subject: |
|
|
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 |
|
 |
eternalcold
Joined: 12 Jun 2008 Posts: 8
|
Posted: Wed Aug 06, 2008 9:58 pm Post subject: |
|
|
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 |
|
 |
Bizibill Guest
|
Posted: Thu Dec 31, 2009 2:06 am Post subject: It works! |
|
|
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
|
Posted: Sun Jan 17, 2010 2:49 am Post subject: Script for Anonymous login |
|
|
How would the script look for an anonymous login? _________________ Chuck Miller |
|
| Back to top |
|
 |
|