Topic "Need to pass the file name from dos to WinSCP"

Author Message
Guest




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
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Use "get %fname%".
_________________
Martin Prikryl
lcaufrie
[View user's profile]

Joined: 2009-02-04
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:

Code:
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:
Quote:
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
What version of WinSCP are you using?
Btw, you have superfluous quote at the end of command.
_________________
Martin Prikryl
lcaufrie
[View user's profile]

Joined: 2009-02-04
Posts: 2
Location: Belgium
This is the version 3.8.2. In the menatime, I solved the problem with the following code:
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
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License