Collect list of filenames from remote directory

Advertisement

Jerrys
Guest

Collect list of filenames from remote directory

Please forgive me is this has been asked before (I am new to this).

Using the ls command to list the files in a remote directory is easy enough. But what I would like to do it to redirect the output of this command to a disk file in the local directory (Windows). In essence, I am just trying to get a list of the files in the remote directory to use for other purposes.

I have looked through the documentation, but I don't see anything that addresses redirection like this.

Any suggestions?

Thank you!
Jerry

Reply with quote

Advertisement

Jerrys
Guest

Sorry ... I forgot to mention that I am using WinSCP 4.16 with the SCP protocol in a scripting file at the command prompt in Windows. The remote computer runs Linux.

Reply with quote

Jerrys
Guest

Never mind, I figured out how to do it from the command line when I call WinSCP.com (I had assumed that I would have to do it from within the session).

And sorry for posting in the wrong forum ...

Reply with quote

sp
Guest

Collect list of filenames from remote directory

Hi Jerrys, i would like to get the list of filenames from remote directory in a text file. How do you manage to solve this issue?

Reply with quote

JerryS
Guest

I am on an Windows workstation and talking to a Linux remote server.

Basically, I set up a script file called "dolist.txt" containing the WINSCP commands that would list the contents of the all the directories on the remote server that I needed. Sort of like this:
ls ../usr/Current/Acrobat/
ls ../usr/Current/ASCII/
ls ../usr/Current/CSV/
exit
Then I started WinSCP like this:
winscp.com <root>:<password>@<ipaddress> /script=dolist.txt > file.txt
(Make sure that you have winscp.com in your search path ... it's easier that way)

Anyway, that put the entire output from all the ls commands into one file (file.txt)

It's not the nicest answer, but at least it got what I needed (for now).

I hope this helps you.
JerryS

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,851
Location:
Prague, Czechia

For this simple task you may try using plink from PuTTY package instead. It allows you to execute a shell command on remote machine. This way you can use formatting capabilities of unix ls command (e.g. to display names only)
plink <user>:<host> -pw <password> ls > file.txt

See also https://winscp.net/eng/docs/script_custom_listing_format_csv
Last edited by martin on 2008-08-29; edited 1 time in total

Reply with quote

Advertisement

You can post new topics in this forum