If you are trying to download the latest/most current file on a linux machine onto a windows machine, THEN move said file to another linux machine using psftp and Windows Task Scheduler you may run into a few roadblocks.
First, psft provides limited linux commands and Task Scheduler does not process any “variables” you may want to access from “included” scripts. SO, what we need to do is define the “variables”, in our case, the most current date along with commands and echo them onto a dynamically created script which we then call once we connect via fstp.
Windows Shell Script Dates: If we want to print out 20150225 (YYYYMMDD):
Year: %date:~-4% is equal to 2015
Month: %date:~4,2% is equal to 02
Day: %date:~7,2% is equal to 25
with our final string looking like: %date:~-4%%date:~4,2%%date:~7,2%
Below is an example of grabbing the latest log file using date variables:
echo mget myLogFile%date:~-4%%date:~4,2%%date:~7,2%* > C:\myFolder\scripts\filetoget.scr
echo mput myLogFile%date:~-4%%date:~4,2%%date:~7,2%* > C:\myFolder\scripts\filetoput.scr
psftp -P [port] userName1@myhost1.com -pw myPassword1 -b C:\myFolder\scripts\filetoget.scr
psftp userName2@myhost2.com -pw myPassword2 -i c:\myFolder\putty\myPuttyKey.ppk -b C:\myFolder\scripts\filetoput.scr
del * /F /Q