Topic "Simple LOG file cration with file content details to local folder"

Author Message
mahen
[View user's profile]

Joined: 2016-09-10
Posts: 2
Location: USA
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
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
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:

Code:
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
mahen
[View user's profile]

Joined: 2016-09-10
Posts: 2
Location: USA
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:

Code:
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
The session log is for debugging, not to get parsed.
Consider using XML log instead:
https://winscp.net/eng/docs/logging_xml

Or use WinSCP .NET assembly, as is does the parsing for you:
https://winscp.net/eng/docs/library_vb
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