Need to pass the file name from dos to WinSCP

Advertisement

Guest

Need to pass the file name from dos to WinSCP

Hi

My requriment is to take the latest file from remote and store it in loacl. The file name is appended with date.
exp: abc01022009.txt.

i am using the below script

@echo off


:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: Find the Current date MMDDYYYY
::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
set DayOfWeek=%%i
set Month=%%j
set Day=%%k
set Year=%%l
)
echo %Month%
echo %Day%
If %Month% LEQ 9 Set LMonth=0%Month%
If %Month% GEQ 10 Set LMonth=%Month%
If %Day% LEQ 9 Set LDay=0%Day%
If %Day% GEQ 10 Set LDay=%Day%

set fname = abc_%LMonth%%LDay%%Year%.TXT

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: Copying the BPD Gun Offender Registry files from FTP server * * *
cd C:\Program files\WinSCP
winscp.com biftp@ftpe:22 /command "lcd C:\backup" "get fname" "exit" /privatekey="C:\keyfiles\id.ppk"


I am not able to get the file name.

Please help to achive this

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
27,209
Location:
Prague, Czechia

Re: Need to pass the file name from dos to WinSCP

Use "get %fname%".
_________________
Martin Prikryl

Reply with quote

lcaufrie
Joined:
Posts:
2
Location:
Belgium

Hello,

I am new on this forum and I have exactly the same problem:

If I use the following codes, it works:

cd C:\Program files\Putty 
winscp3.exe TNG /console /command " cd /usr/users/IOT/logs/TasksLogByDay" "get Tasks_20090203.log S:\ITN_SSM\SSM_CC\CC_COM~1\CC_KPI\Workload\2009\SMCDAT~1\oprlog.txt"  "    

but when I use the following:
set fname = Tasks_20090203.log

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: Copying the BPD Gun Offender Registry files from FTP server * * *
cd C:\Program files\Putty
winscp3.exe TNG /console /command " cd /usr/users/IOT/logs/TasksLogByDay" "get %fname%

S:\ITN_SSM\SSM_CC\CC_COM~1\CC_KPI\Workload\2009\SMCDAT~1\oprlog.txt" "

I get the error message:
Can't get attributes of file 'S:\ITN_SSM\SSM_CC
CDAT~1\oprlog.txt'.
No such file or directory.
Error code: 2
Error message from server: No such file
Request code: 7

Any help is welcome.
Thanks in advance
Laurent

Reply with quote E-mail

martin
Site Admin
martin avatar
Joined:
Posts:
27,209
Location:
Prague, Czechia

What version of WinSCP are you using?
Btw, you have superfluous quote at the end of command.
_________________
Martin Prikryl

Reply with quote

lcaufrie
Joined:
Posts:
2
Location:
Belgium

This is the version 3.8.2. In the menatime, I solved the problem with the following code:
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do ( 
echo Tasks_%%k%%j%%i.log

set Day=%%i 
set Month=%%j 
set Year=%%k 

cd C:\Program files\Putty 

winscp3.exe TNG /console /command "option confirm off" "cd /usr/users/IOT/logs/TasksLogByDay" "get Tasks_%%k%%j%%i.log S:\ITN_SSM\SSM_CC\CC_COM~1\CC_KPI\Workload\2009\SMCDAT~1\oprlog.txt" "cd /usr/users/IOT/tmp/cmu" "get Hlisting.txt S:\ITN_SSM\SSM_CC\CC_COM~1\CC_KPI\Workload\2009\SMCDAT~1\Hlisting.txt"

)    
Thanks for your reply

Reply with quote E-mail

Advertisement

You can post new topics in this forum