Simple LOG file cration with file content details to local folder

Advertisement

mahen
Joined:
Posts:
2
Location:
USA

Simple LOG file cration with file content details to local folder

Simple LOG file cration with file content details to local folder

SEPT10,2016.

Greetings to WinSCP Forum members.
Please help me if any one know solution for below log file issue.

How to write a log file for the simple connectivity to a directory in SFTP folder.
Based on below line of code I dont see any log file created in my local folder, either the code is incorrect or something missing.

------------------------------------------------------------------------------------

open sftp://username:example.com:10022/ -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
echo connected to username mailbox...
get *.zip
ls
echo auto-logging...
C:\Program Files (x86)\WinSCP\WinSCP.com sftp://username:example.com/ /log="C:\test\autowinscp\winscp.log"
exit

------------------------------------------------------------------------------------

In above code snippet the connection establishes and works fine when I called above code in autowinscp.txt file with CALL function in VBA.
Except I dont see winscp.log getting created in local directory (C:\test\autowinscp)

Please let me know is there something in correct in above log file writing syntax.

The original requirement was
when user connects the existing sftp folder based on above script,

if any file(like.zip or any other file) is available in the SFTP folder need to return with available file list and timestamp in log file.
if no file is available in the SFTP folder need to return with zero file status in log file

Thanks for any help here with simple log file creation.

Regards

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,392
Location:
Prague, Czechia

Re: Simple LOG file cration with file content details to local folder

It seem that you combine WinSCP script with a batch file/WinSCP command-line in a single file.

In VBA, you have to call a command like:
C:\Program Files (x86)\WinSCP\WinSCP.com /script="c:\test\winscp.txt" /log="C:\test\autowinscp\winscp.log"

Where the winscp.txt should contain:

open sftp://username:example.com:10022/ -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
echo connected to username mailbox...
get *.zip
ls
exit

Reply with quote

mahen
Joined:
Posts:
2
Location:
USA

Re: Simple LOG file creation with file content details to local folder

Thanks for clarification Martin.
I changed my VBA code like below & it worked and created the log file dynamically:
------------------------
Call Shell("C:\Program Files (x86)\WinSCP\WinSCP.com /script=C:\test\autowinscp\autowinscp.txt /log=C:\test\autowinscp\winscp.log", vbNormalFocus)
------------------------

I am looking for few other clarifications on simple log file.

Is it possible or is there an option strip log file to display less number of lines, instead 40 lines of log (this number I just counted number of default rows in log file between start and EOF message)
All I need is below line, along with start and end, I took these three lines from current log file which has 37 other lines with other parameters which may not required.
------------------------
. 2016-09-12 09:36:02.571 Started a shell/command
. 2016-09-12 09:36:03.042 Script: Drwxrwxrwx 0 0 Sep 12 9:36:03 2016 ..
. 2016-09-12 09:36:03.045 Sent EOF message
------------------------

Please let me know if there are options to turn of other parameters in log file.

Thank you.
Have a nice day!


martin wrote:

It seem that you combine WinSCP script with a batch file/WinSCP command-line in a single file.

In VBA, you have to call a command like:
C:\Program Files (x86)\WinSCP\WinSCP.com /script="c:\test\winscp.txt" /log="C:\test\autowinscp\winscp.log"

Where the winscp.txt should contain:

open sftp://username:example.com:10022/ -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
echo connected to username mailbox...
get *.zip
ls
exit

Reply with quote

Advertisement

You can post new topics in this forum