Topic "Listing a file using Winscp script command "ls" return error"

Author Message


Hi everyone,

I'm trying to list a specific file from a directory in a sftp server. I'm using Winscp 4.2.5 and the script command "ls"

ls Nxxxxxxxxxxxxxxxxxxx-xxxxxxxxx.jpg

But the server always respond:
Error listing directory 'Nxxxxxxxxxxxxxxxxxxx-xxxxxxxxx.jpg'.
General failure (server should provide error description).
Error code: 4
Error message from server: "/Nxxxxxxxxxxxxxxxxxxx-xxxxxxxxx.jpg": directory not found.
Request code: 11

Rewriting the script in that way:

ls *Nxxxxxxxxxxxxxxxxxxx-xxxxxxxxx.jpg
It's working fine but it could have some problems if there more files with the same name and starting with other letters or characters.

I have the same problem with others commands to download (get), to upload(put) and to delete (rm). So that I can not, for example, delete a particular file without running the risk of deleting any more due to the use of the asterisk at the beginning of the filename.

At the begining, I was thinking the problem could be on the server configuration. And I can't do anything about that because the server isn't mine. But installing a SFTP server in other computer to makes some test, I found the same problem. So now I'm thinking that the script lenguage require this * to works fine.

I have to admit that this is the first time I'm programming with scripting languages to interact with an SFTP or an FTP server. I've always used graphical environments such as filezilla or winscp's own. And I've been looking at the page of winscp some information on the use of script commands in the forums, in the news ...... in other pages. Well I don't know where to look. Must be a stupid mistake on my part but I'm starting to get desperate

Someone could help me please.

Thanks a lot.
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25310
Location: Prague, Czechia
Command "ls" does not support listing of single file. Though "get", "put" and "rm" can handle single file.
Martin Prikryl

martin wrote:
Command "ls" does not support listing of single file. Though "get", "put" and "rm" can handle single file.

Ok, I tested it again and It's works fine. I don't know what I did to think the commands "get", "put" and "rm" needs a "*" to works. Now I don't have any problems. Thanks a lot.

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!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License