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

Advertisement

Fenris
Guest

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

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 beggining, 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 language 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.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Listing a file using Winscp script command "ls" return error

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

Reply with quote

Guest

Re: Listing a file using Winscp script command "ls" return error

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 work. Now I don't have any problems. Thanks a lot.

Reply with quote

Advertisement

You can post new topics in this forum