Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: no log for ls/dir command's output

I believe WinSCP lists it when using passive mode. Cannot test it now, so I'm not sure.
Jason

Re: no log for ls/dir command's output

For simple text logging, why not simply log the output of ls, just like DOS Command Window. That way at least we have log and can do further parsing.
martin

Re: log files posted

jason wrote:

Question: how to log both execusion trace and the ls output?

You cannot have both.
jason

log files posted

Change log file extension to .xml does capture the ls output. Thanks a lot.

XML log content is as follow:

<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="https://winscp.net/schema/session/1.0" name="ftpUser@localhost" start="2010-06-07T14:27:08.965Z">
<upload>
<filename value="aaa.txt" />
<destination value="/TargetFolder/aaa.txt" />
<result success="true" />
</upload>
<ls>
<destination value="/TargetFolder" />
<files>
<file>
<filename value=".." />
<type value="D" />
<modification value="1899-12-30T04:00:00.000Z" />
<permissions value="---------" />
</file>
<file>
<filename value="aaa.txt" />
<type value="-" />
<size value="76853774" />
<modification value="2010-06-07T14:27:00.000Z" />
<permissions value="---------" />
</file>
</files>
<result success="true" />
</ls>
</session>



Original log file's extension is .log. Content is as follow, the execution trace without ls output:

. 2010-06-04 17:03:28.121 --------------------------------------------------------------------------
. 2010-06-04 17:03:28.121 WinSCP Version 4.2.6 (Build 721) (OS 5.1.2600 Service Pack 3)
. 2010-06-04 17:03:28.121 Login time: Friday, June 04, 2010 5:03:28 PM
. 2010-06-04 17:03:28.121 --------------------------------------------------------------------------
. 2010-06-04 17:03:28.121 Session name: ftpUser@localhost
. 2010-06-04 17:03:28.121 Host name: localhost (Port: 21)
. 2010-06-04 17:03:28.121 User name: ftpUser (Password: Yes, Key file: No)
. 2010-06-04 17:03:28.121 Tunnel: No
. 2010-06-04 17:03:28.121 Transfer Protocol: FTP
. 2010-06-04 17:03:28.121 Ping type: C, Ping interval: 30 sec; Timeout: 15 sec
. 2010-06-04 17:03:28.121 Proxy: none
. 2010-06-04 17:03:28.121 FTP: FTPS: None; Passive: No [Force IP: No]
. 2010-06-04 17:03:28.121 Local directory: default, Remote directory: home, Update: No, Cache: Yes
. 2010-06-04 17:03:28.121 Cache directory changes: Yes, Permanent: Yes
. 2010-06-04 17:03:28.121 DST mode: 1
. 2010-06-04 17:03:28.121 --------------------------------------------------------------------------
. 2010-06-04 17:03:28.121 Connecting to localhost ...
. 2010-06-04 17:03:28.121 Connected with localhost. Waiting for welcome message...
< 2010-06-04 17:03:28.121 220 Microsoft FTP Service
> 2010-06-04 17:03:28.121 USER ftpUser
< 2010-06-04 17:03:28.121 331 Password required for ftpUser.
> 2010-06-04 17:03:28.121 PASS ****
< 2010-06-04 17:03:28.121 230-You have conencted to test site
< 2010-06-04 17:03:28.121 230 User ftpUser logged in.
> 2010-06-04 17:03:28.121 SYST
< 2010-06-04 17:03:28.121 215 Windows_NT
> 2010-06-04 17:03:28.121 FEAT
< 2010-06-04 17:03:28.121 500 'FEAT': command not understood
. 2010-06-04 17:03:28.121 Connected
. 2010-06-04 17:03:28.121 --------------------------------------------------------------------------
. 2010-06-04 17:03:28.121 Using FTP protocol.
. 2010-06-04 17:03:28.121 Doing startup conversation with host.
> 2010-06-04 17:03:28.121 PWD
< 2010-06-04 17:03:28.121 257 "/" is current directory.
. 2010-06-04 17:03:28.121 Getting current directory name.
. 2010-06-04 17:03:28.121 Startup conversation with host finished.
. 2010-06-04 17:03:28.121 Cached directory change via "/TargetFolder" to "/TargetFolder".
. 2010-06-04 17:03:28.121 Getting current directory name.
. 2010-06-04 17:03:28.121 Copying 1 files/directories to remote directory "/TargetFolder"
. 2010-06-04 17:03:28.121 PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 01; Resume: S (102400); CalcS: No; Mask:
. 2010-06-04 17:03:28.121 TM: M; ClAr: No; CPS: 0; ExclM(No):
. 2010-06-04 17:03:28.121 AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2010-06-04 17:03:28.121 File: "aaa.txt"
. 2010-06-04 17:03:28.121 Copying "aaa.txt" to remote directory started.
. 2010-06-04 17:03:28.121 Ascii transfer mode selected.
. 2010-06-04 17:03:28.121 Starting upload of aaa.txt
> 2010-06-04 17:03:28.121 CWD /TargetFolder/
< 2010-06-04 17:03:28.121 250 CWD command successful.
> 2010-06-04 17:03:28.121 PWD
< 2010-06-04 17:03:28.121 257 "/TargetFolder" is current directory.
> 2010-06-04 17:03:28.121 TYPE A
< 2010-06-04 17:03:28.121 200 Type set to A.
> 2010-06-04 17:03:28.121 PORT 127,0,0,1,4,248
< 2010-06-04 17:03:28.121 200 PORT command successful.
> 2010-06-04 17:03:28.121 LIST
< 2010-06-04 17:03:28.121 150 Opening ASCII mode data connection for /bin/ls.
< 2010-06-04 17:03:28.136 226 Transfer complete.
> 2010-06-04 17:03:28.136 TYPE A
< 2010-06-04 17:03:28.136 200 Type set to A.
> 2010-06-04 17:03:28.136 PORT 127,0,0,1,4,249
< 2010-06-04 17:03:28.136 200 PORT command successful.
> 2010-06-04 17:03:28.136 STOR aaa.txt
< 2010-06-04 17:03:28.136 150 Opening ASCII mode data connection for aaa.txt.
< 2010-06-04 17:03:34.792 226 Transfer complete.
. 2010-06-04 17:03:34.792 Upload successful
. 2010-06-04 17:03:34.792 Disconnected from server


Once change extension from .log to .xml, the excusion traceis gone.
Question: how to log both execusion trace and the ls output?
martin

Re: no log for ls/dir command's output

Please post a sample of the log file. Also are you sure you log path has .xml extension?
jason

no log for ls/dir command's output

I didn't see any ouput for the ls or dir command in the log file. Though I do see the output in dos command window. What could go wrong? My purpose is after a file is uploaded, check if the file is there, the size and the time stamp of the file, then compare with local file. If both match, then the upload is compete. Here is my code:

Process winscp = new Process();

winscp.StartInfo.FileName = "c:\\program files\\winscp\\winscp.com";
winscp.StartInfo.Arguments = string.Format("/log={0}", ftpLogFileFullName);
winscp.StartInfo.UseShellExecute = false;
winscp.StartInfo.RedirectStandardInput = true;
winscp.StartInfo.CreateNoWindow = true;

winscp.StandardInput.WriteLine("option batch abort");
winscp.StandardInput.WriteLine("option confirm off");
winscp.StandardInput.WriteLine(string.Format("open {0}", Dts.Variables["_ftpConnectionString"].Value));

winscp.StandardInput.WriteLine(string.Format("cd {0}", Dts.Variables["ftpRemotePath"].Value));
winscp.StandardInput.WriteLine(string.Format("put {0}", ftpSourceFileFullName));

// ls command does not work the way it supposes to be, no output is logged
winscp.StandardInput.WriteLine(string.Format("ls"));

winscp.StandardInput.WriteLine("exit");

winscp.StandardInput.Close();

winscp.WaitForExit();