0

I want to connect to the linux machine with WinSCP(command line) from Windows. and I want to get logs.

There are logs in linux machine

/var/log/application/
090701.log
090702.log
090703.log
090704.log
090705.log

winscp sftp://account:pass@machine:22 How to get logs efficiently?

freddiefujiwra
  • 1,667
  • 5
  • 25
  • 34

3 Answers3

4

If you're using scripting I think it's time for you to read the WinSCP documentation. Last time I looked it contained examples that show exactly how to do what you want.

Of course if you're using the GUI just drag them over to your Windows folders within the WinSCP interface.

John Gardeniers
  • 27,458
  • 12
  • 55
  • 109
2

I have a similar solution using winscp scripting, mine looks like this:

winscp Script:

option batch continue
option confirm off
open logs:*******@10.x.x.x
synchronize remote "c:\daily_logs\*" ./81/
synchronize remote "c:\daily_logs\" ./81/
close
exit

I use iCronService, which works on every version of windows I have tried it on, including x64 based ones, and this is what my crontab looks like:

crontab:

00 22 * * * cmd /c "winscp /console /script=c:\bin\scplogs /log=LOG_OF_SCP.LOG"

One could also compress the logs first to save some time, bandwidth, and space. Surely this is not the most elegant solution because the password is hardcoded into the scp script, but could be replaced with keys if you like.

matt
  • 1,152
  • 1
  • 8
  • 18
0

You can also use psftp.exe to do the job with a command line like this one:

psftp.exe username@server -be -pw user_password -b c:\script.txt"  

Script.txt may contain for example:

lcd c:\my_backup
get /var/log/application/*
Maxwell
  • 5,076
  • 1
  • 26
  • 31