Topic "Error Downloading File - Wildcard Issue?"

Author Message
JasonRkr
[View user's profile]

Joined: 2013-07-24
Posts: 13
Location: Sunny Southern California
Group,

I'm receiving a file not found error when trying to download a file using a wildcard in the name. However, when I use the full file name it works without issue. Below is a section of the DebugLog file in the hopes it may provide additional detail. Also, the server I'm downloading from is running AIX 6.

<session xmlns="https://winscp.net/schema/session/1.0" name="qcupload@vm6klab1" start="2013-08-14T21:07:07.742Z">
<group name="open -hostkey=&quot;ssh-rsa 2048 0e:2b:76:24:bf:50:e7:29:f5:01:2b:e6:59:16:ea:10&quot; -timeout=15 sftp://qcupload:***@vm6klab1" start="2013-08-14T21:07:08.539Z">
</group>
<group name="stat -- &quot;/U/softprint/FTP14*.x&quot;" start="2013-08-14T21:07:08.664Z">
<stat>
<filename value="/U/softprint/FTP14*.x" />
<result success="false">
<message>Can't get attributes of file '/U/softprint/FTP14*.x'.</message>
<message>No such file or directory.
Error code: 2
Error message from server: No such file
Request code: 7</message>
</result>
</stat>
<failure>
<message>Can't get attributes of file '/U/softprint/FTP14*.x'.</message>
<message>No such file or directory.
Error code: 2
Error message from server: No such file
Request code: 7</message>
</failure>
</group>
<group name="exit" start="2013-08-14T21:07:08.789Z">
</group>
</session>

Thank you,

Jason
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
For download (Session.GetFiles, note the plural) you can indeed use wildcards. But from the log, I suppose you are using Session.FileExists (note the singular) first, that does not support wildcards:
https://winscp.net/eng/docs/library_session_fileexists
_________________
Martin Prikryl
JasonRkr
[View user's profile]

Joined: 2013-07-24
Posts: 13
Location: Sunny Southern California
Martin,

I'm using the PowerShell sample code provided at https://winscp.net/eng/docs/library_session_getfiles#example. I've just changed the variables to match my server.

Code:

if ($download)
{
    # Download the file and throw on any error
    $session.GetFiles($remotePath, $localPath).Check()
    Write-Host "Download to backup done."
}


Jason
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
Ok, but I suppose you set the fileName to FTP14*.x.

As the example, you refer to, calls session.FileExists(remotePath) before calling session.GetFiles(remotePath, localPath), it fails. You probably do not want the check at all. Just remove it.

Also note that the example does not use wildcards, nor mentions anywhere that you can use wildcards for it.

Anyway this is really just an code sample. If you want its functionality, including wildcard support, use the simple code mentioned in comments:
Code:
// You can achieve the same using:
session.SynchronizeDirectories(
    SynchronizationMode.Local, localPath, remotePath, false, false, SynchronizationCriteria.Time,
    new TransferOptions { IncludeMask = fileName }).Check();
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