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

martin
Site Admin
martin avatar
Joined:
Posts:
27,209
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

Last edited by martin on 2008-08-29; edited 1 time in total

Reply with quote

Jerrys
Guest

Thank you! I'll take a look at Putty.

By the way, in reference to the topic of transferring files between two servers via a local workstation ...

I guess I am lucky ... from my Windows XP workstation, I have to deal with a Redhat Linux server as well as a Windows Server 2003 server. I found that if I make a mapped drive to a folder structure on the Windows server, WinSCP will treat that mapped drive as a local drive and the file transfers between the two remote servers works beautifully.

Just thought I would mention that in case someone else is in the same situation.

Thanks again for your help!
Jerry

Reply with quote

Advertisement

You can post new topics in this forum