Command line to download file without popup

Advertisement

DrOnline
Joined:
Posts:
2
Location:
Norway

Command line to download file without popup

Hi,

I'm new to this program (5.15.3 (Build 9730), Windows 10 64-bit), and I am sure my error is trivial. Hope somebody can help me out.

I'm trying to use SCP to download a file from a remote system onto my local system, and also rename the file.

The problem is that this command brings up the WinSCP GUI (which I could like to suppress), and logs into the remote system fine, and I see there is a logfile2.log under /root/, which is correct, but I want it to automatically rename it to C:\logs\19-1234.log with no confirmation or popups of any kind. Using all my variants of the command I get a "Download"-popup and I have to point it to the location I want to download the file. I'm running CMD and winSCP as administrator.

Here is what I have tried:
C:\Program Files (x86)\WinSCP>WinSCP.exe scp://root:root@192.168.2.47:22/root/logfile2.log c:\logs\heh.log
C:\Program Files (x86)\WinSCP>WinSCP.exe scp://root:root@192.168.2.47:22/root/logfile2.log c:\logs\heh.log
C:\Program Files (x86)\WinSCP>WinSCP.exe scp://root:root@192.168.2.47:22 get /root/logfile2.log c:\logs\heh.log
C:\Program Files (x86)\WinSCP>WinSCP.exe scp://root:root@192.168.2.47:22 get /root/logfile2.log c:\logs\
C:\Program Files (x86)\WinSCP>WinSCP.exe scp://root:root@192.168.2.47:22/root/ get logfile2.log c:\logs\
C:\Program Files (x86)\WinSCP>WinSCP.exe scp://root:root@192.168.2.47:22/root/ get logfile2.log c:\logs\
C:\Program Files (x86)\WinSCP>WinSCP.exe scp://root:root@192.168.2.47:22/opt/ get logfile2.log c:\logs\
C:\Program Files (x86)\WinSCP>WinSCP.exe scp://root:root@192.168.2.47:22/root get logfile2.log c:\logs\
C:\Program Files (x86)\WinSCP>WinSCP.exe scp://root:root@192.168.2.47:22/root/logfile2.log c:\logs\19-1234.log
C:\Program Files (x86)\WinSCP>WinSCP.exe scp://root:root@192.168.2.47:22/root/logfile2.log 19-1234.log
C:\Program Files (x86)\WinSCP>WinSCP.exe scp://root:root@192.168.2.47/root/logfile2.log 19-1234.log
C:\Program Files (x86)\WinSCP>WinSCP.exe scp://root:root@192.168.2.47/root/logfile2.log C:\logs\19-1234.log

Reply with quote

Advertisement

Guest

Thanks, I'll read that documentation and try making a script. I wanted to use a batch file anyway. I was lazily hoping to be handed the correct syntax, but I'll write a solution and post it here afterwards.

Reply with quote

DrOnline
Joined:
Posts:
2
Location:
Norway

Batch file:

@REM The script will download log file and save it with unique name.
@REM Syntax example: GetLog 47 19-123456
echo Downloading logfile from %1 and saving it as C:\logs\%2.log
cd C:\Program Files (x86)\WinSCP\
winscp.com /ini=nul /script=c:\logs\DLscript.txt /parameter %1
@REM Renames and moves logfile
copy c:\logs\tmp\logfile2.log c:\logs\%2.log

winSCP script file:

open scp://root:root@192.168.2.%1%:22 -hostkey="*"
get /root/logfile2.log c:\logs\tmp\
exit

Reply with quote

Advertisement

You can post new topics in this forum