trying to grab a file from ftp with date variable name

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
schnarkle
Posts: 21
Joined: 29 Mar 2016, 16:47

trying to grab a file from ftp with date variable name

05 Apr 2018, 17:23

Hi I'm trying to download a file every day by today's date. The format is MTR_040518.pdf.

Here is the code:

Code: Select all

WinClose, ahk_class AcrobatSDIWindow

Sleep, 1000

WinClose, ahk_class AcrobatSDIWindow

SetWorkingDir, C:\


FormatTime, MyFile,, 'MTR_'MM''dd''yy'.pdf'


RunWait % "curl.exe -v -o c:\scripts\%MyFile% ftp://ftp.themonitor.com/lobby/%MyFile% --user username:password"

Sleep, 20000


Run, c:\scripts\%MyFile%

Sleep, 20000

Send ^l

Sleep, 20000

Send ^2


Pause

But I get the error here when running? It looks like it's outputting the name correctly but the file is not being downloaded even though it is there and named exactly like the script seems to show.
why.png
why.png (22.73 KiB) Viewed 1198 times
any ideas please?
neverlevel
Posts: 60
Joined: 13 Apr 2016, 22:02

Re: trying to grab a file from ftp with date variable name

05 Apr 2018, 17:40

i dont think its not getting the file...i think maybe its not running curl??
schnarkle
Posts: 21
Joined: 29 Mar 2016, 16:47

Re: trying to grab a file from ftp with date variable name

06 Apr 2018, 10:15

It is running curl because if I manually type the filename in the script without the date variable (MTR_040518.pdf literal) it works.
Maybe autohotkey sees the date variable one way but curl in another?

thanks
User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: trying to grab a file from ftp with date variable name

06 Apr 2018, 13:35

RunWait % "curl.exe -v -o c:\scripts\" MyFile " ftp://ftp.themonitor.com/lobby/" MyFile " --user username:password"

%MyFile% inside quotes will not be expanded. Everything in "Quotes" is literal. So you are literally trying to download and create a file named "%MyFile%".

Or you could do this:
RunWait curl.exe -v -o c:\scripts\%MyFile% ftp://ftp.themonitor.com/lobby/%MyFile% --user username:password

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: trying to grab a file from ftp with date variable name

06 Apr 2018, 13:49

Code: Select all

%MyFile% inside quotes will not be expanded. Everything in "Quotes" is literal. So you are literally trying to download and create a file named "%MyFile%".
... and the reason for that, you've initialized a :arrow: [forced expression]
Force an expression: An expression can be used in a parameter that does not directly support it (except OutputVar parameters) by preceding the expression with a percent sign and a space or tab. In [v1.1.21+], this prefix can be used in the InputVar parameters of all commands except the traditional IF commands (use If (expression) instead). This technique is often used to access arrays.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750, septrinus and 246 guests