Topic "Download Most Recent File Problem"

Author Message
comj

Guest


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
Advertisements
comj

Guest


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");
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
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.
_________________
Martin Prikryl
comj

Guest


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


I upgraded and it works now.... Smile

Thanks!
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