FTP File Transfer Script
The examle below does not work every time. I believe I need to use a TXT file for the FTP script part instead of typing it in. It appears either the cmd.exe window or the FTP connection does not really close and remains running or something. I have changed the IP address and login information for obvious reasons!
Home:
InputBox, JobNo, SmartSCRIPT Get 20 PHX Job, Enter Job No., ,250, 150
if ErrorLevel <> 0
Gosub, Finish
else
Gosub, Cont
Cont:
WinMinimize
Run, cmd
WinWait, C:\WINDOWS\system32\cmd.exe,
IfWinNotActive, C:\WINDOWS\system32\cmd.exe, , WinActivate, C:\WINDOWS\system32\cmd.exe,
WinWaitActive, C:\WINDOWS\system32\cmd.exe,
Send, cd{SPACE}\ascend{ENTER}md{SPACE}Voice{ENTER}cd{SPACE}Voice{ENTER}
Send, ftp{SPACE}000.000.000.000{ENTER}
Send, user{SPACE}user{SPACE}pwd{ENTER}
WinWait, C:\WINDOWS\system32\cmd.exe - ftp,
IfWinNotActive, C:\WINDOWS\system32\cmd.exe - ftp, , WinActivate, C:\WINDOWS\system32\cmd.exe - ftp,
WinWaitActive, C:\WINDOWS\system32\cmd.exe - ftp,
Send, cd{SPACE}/assigned/20{ENTER}prompt{ENTER}hash{ENTER}mget{SPACE}%JobNo%.*{ENTER}disconnect{ENTER}quit{ENTER}
WinWait, C:\WINDOWS\system32\cmd.exe,
IfWinNotActive, C:\WINDOWS\system32\cmd.exe, , WinActivate, C:\WINDOWS\system32\cmd.exe,
WinWaitActive, C:\WINDOWS\system32\cmd.exe,
Send, exit{ENTER}
WinWaitClose, C:\WINDOWS\system32\cmd.exe - ftp
WinWaitClose, C:\WINDOWS\system32\cmd.exe
Gosub, Home
Finish:
Exit
CleanNews.in : Bite sized latest news headlines from India with zero bloat
InputBox, JobNo, SmartSCRIPT Get 20 PHX Job, Enter Job No., ,250, 150
if ErrorLevel <> 0
{
MsgBox, Error !
ExitApp
}
RunWait, %COMSPEC% /C cd ascend,,Hide
RunWait, %COMSPEC% /C md Voice,,Hide
RunWait, %COMSPEC% /C cd Voice,,Hide
FileAppend, user JohnDoe`npwd MyPassword`ncd /assigned/20`nprompt hash`nmget %JobNo%.*`ndisconnect`nquit`n, MyFTPDownload.txt
RunWait, %COMSPEC% /C ftp 000.000.000.000 -s:MyFTPDownload.txt,,Hide
FileDelete, MyFTPDownload.txt
MsgBox, Done.
ExitApp
As usual.
Untested braindump :roll:
Uncommented. :oops:
8)
Any ideas? It SHOULD work...
Creates a directory.
MKDIR [drive]path
MD [drive]path
If Command Extensions are enabled MKDIR changes as follows:
MKDIR creates any intermediate directories in the path, if needed.
For example, assume \a does not exist then:
mkdir \a\b\c\d
is the same as:
mkdir \a
chdir \a
mkdir b
chdir b
mkdir c
chdir c
mkdir d
which is what you would have to type if extensions were disabled.
Additionaly you should use within the FTP file --> lcd (change the local directory) to swap to the local directory /ascend/VoiceRunWait, %COMSPEC% /C md \ascend\Voice,,Hide
Thanks for sharing that. It might help until such time as AutoHotkey supports HTTP/FTP uploading, which might be a while. (Chris wrote)
It would be really nice if there were FTP/HTTP upload/download engines!
...
InputBox, JobNo, SmartSCRIPT Get 20 PHX Job, Enter Job No., ,250, 150
:idea: Guess it's: Please enter "Job number"
You can do the dynamic part of the FTP up-/download using the "-s:filename" argument of the FTP command.
InputBox, JobNo, SmartSCRIPT Get 20 PHX Job, Enter Job No., ,250, 150
if ErrorLevel <> 0
{
MsgBox, Error !
ExitApp
}
RunWait, %COMSPEC% /C cd ascend,,Hide
RunWait, %COMSPEC% /C md Voice,,Hide
RunWait, %COMSPEC% /C cd Voice,,Hide
FileAppend, user JohnDoe`npwd MyPassword`ncd /assigned/20`nprompt hash`nmget %JobNo%.*`ndisconnect`nquit`n, MyFTPDownload.txt
RunWait, %COMSPEC% /C ftp 000.000.000.000 -s:MyFTPDownload.txt,,Hide
FileDelete, MyFTPDownload.txt
MsgBox, Done.
ExitApp
As usual.
Untested braindump :roll:
Uncommented. :oops:
8)
This is a security issue. If AHK get's native support for uploading files, this would open the way to creating trojans/spyware with AHK.
Ofcourse one can run the ftp command line utility, use a few dllcalls and bypass security too, but that is still different from native support, malign actions would be far easier to track with an antivirus/trojan scanner/firewall without support for upping in AHK...
Also, BoBo's method above is quite useful. It can be further improved via a continuation section. At the bottom of the FileAppend page, there's is a complete example of performing uploads and other tasks on an FTP server.