Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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

comj

Re: script is missing something

martin wrote:

What version of WinSCP are you using? Make sure you use the latest one.


I upgraded and it works now.... :)

Thanks!
martin

Re: script is missing something

comj wrote:

It seems like the script is just missing a whole section; unless the log file is supposed to be written out in XML (which it's not).

What version of WinSCP are you using? Make sure you use the latest one.
comj

script is missing something

It seems like the script is just missing a whole section; unless the log file is supposed to be written out in XML (which it's not).

// run winscp to get list of file in the remote directory into XML log -- which I don't think it's an XML log...rather just a text file with ".xml" at the end.
exec = shell.Exec("\"" + WINSCP + "\" /log=\"" + logfilepath + "\"");
exec.StdIn.Write(
"option batch abort\n" +
"open \"" + SESSION + "\"\n" +
"ls \"" + REMOTEPATH + FILEMASK + "\"\n" +
"exit\n");

// wait until the script finishes
while (exec.Status == 0)
{
WScript.Sleep(100);
WScript.Echo(exec.StdOut.ReadAll()); //Here is where it shows you all the files it found
}

// It seems like right here there should be output to XML format or something.

if (exec.ExitCode != 0)
{
WScript.Echo("Error retrieving list of files");
WScript.Quit(1);
}

// look for log file
var logfile = filesys.GetFile(logfilepath);

if (logfile == null)
{
WScript.Echo("Cannot find log file");
WScript.Quit(1);
}

// parse XML log file
var doc = new ActiveXObject("MSXML2.DOMDocument");
doc.async = false;
doc.load(logfilepath);

doc.setProperty("SelectionNamespaces",
"xmlns:w='https://winscp.net/schema/session/1.0'");

var nodes = doc.selectNodes("//w:file");
comj

Download Most Recent File Problem

I'm trying to get this script to run:

https://winscp.net/eng/docs/script_download_most_recent_file

but it says no files available even tho there are a ton. What's weird is that the line:

WScript.Echo(exec.StdOut.ReadAll());

echos out all the files....

Here is how the XML file ends:

2010-01-18 18:16:51.149 Access granted
. 2010-01-18 18:16:51.206 Opened channel for session
. 2010-01-18 18:16:51.260 Started a shell/command
. 2010-01-18 18:16:51.261 --------------------------------------------------------------------------
. 2010-01-18 18:16:51.261 Using SFTP protocol.
. 2010-01-18 18:16:51.262 Doing startup conversation with host.
> 2010-01-18 18:16:51.263 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2010-01-18 18:16:51.317 Type: SSH_FXP_VERSION, Size: 5, Number: -1
. 2010-01-18 18:16:51.318 SFTP version 3 negotiated.
. 2010-01-18 18:16:51.318 We believe the server has signed timestamps bug
. 2010-01-18 18:16:51.318 We will use UTF-8 strings for status messages only
. 2010-01-18 18:16:51.318 Getting current directory name.
. 2010-01-18 18:16:51.319 Getting real path for '.'
> 2010-01-18 18:16:51.319 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2010-01-18 18:16:51.409 Type: SSH_FXP_NAME, Size: 95, Number: 16
. 2010-01-18 18:16:51.409 Real path is '/'
. 2010-01-18 18:16:51.409 Startup conversation with host finished.
. 2010-01-18 18:16:51.410 Listing directory "/download".
> 2010-01-18 18:16:51.410 Type: SSH_FXP_OPENDIR, Size: 35, Number: 267
< 2010-01-18 18:16:52.151 Type: SSH_FXP_HANDLE, Size: 10, Number: 267
> 2010-01-18 18:16:52.151 Type: SSH_FXP_READDIR, Size: 10, Number: 524
< 2010-01-18 18:16:52.367 Type: SSH_FXP_NAME, Size: 5836, Number: 524
> 2010-01-18 18:16:52.367 Type: SSH_FXP_READDIR, Size: 10, Number: 780
< 2010-01-18 18:16:52.421 Type: SSH_FXP_STATUS, Size: 30, Number: 780
< 2010-01-18 18:16:52.421 Status/error code: 1
> 2010-01-18 18:16:52.421 Type: SSH_FXP_CLOSE, Size: 10, Number: 1028
. 2010-01-18 18:16:52.425 Closing connection.
. 2010-01-18 18:16:52.425 Sending special code: 12
. 2010-01-18 18:16:52.425 Sent EOF message