WINSCP synchronize alternatives?

I want to get a directory listing of a remote directory into a textfile using a WINSCP script.  I'm getting "too many parameters for ls command" message.  I've concluded that redirection is not an option.  

Will some wonderful expert please look at this and let me know how I can get a directory listing into a textfile using a WINSCP script?  Thanks.

open ftp://<user>:<pwd>@<ip address>
cd <main folder>
cd <sub folder>
ls > listoffiles.txt
get listoffiles.txt
exit

Open in new window

MariaHaltAsked:
Who is Participating?
 
woolmilkporcConnect With a Mentor Commented:
I think winscp.exe /console opens a new window so that output redirection cannot work.
Use winscp.com instead. It provides the console interface.
wmp
 
0
 
woolmilkporcCommented:
Omit the redirection operator. ls in this context takes only one parameter - the name of a local output file.
0
 
MariaHaltAuthor Commented:
Tried it, but now I'm getting these errors instead:

Error listing directory 'listoffiles.txt'
and
Could not retrieve directory listing

It's like ls can't be redirected in WINSCP.

0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
woolmilkporcCommented:
OK, obviously you're right. WinSCP obviously doesn't support the 'classic' FTP syntax.
The only thing which seems to work is redirecting the whole output of winscp.exe (or winscp.com) by using standard operators > or |  -
 winscp.exe .... > outfile
The headline of your Q contains 'synchronize ...'. Did you consider using the 'synchronize' facility of WinSCP? Has nothing to do with output redirection, I know ...
wmp
0
 
MariaHaltAuthor Commented:
I removed everything to the right of the ls command and got rid of the get line too, hoping that the listing would appear in the results.txt file.

I've been running the script from a batch file that contains this line:

C:\PROGRA~1\WinSCP\winscp.exe /console /script=C:\TEMP\mywinscpscript.txt > results.txt

The file, results.txt, is empty!  

As for the synchronize command...it has its own set of problems...the remote directory is huge and the local directory is flushed daily...so what happens is all the files in the remote directory get downloaded (again and again)...some are huge and a problem inevitably occurs and the synchronization starts over...it's just not working out.  ( I meant to change that headline.)

I appreciate your help.
0
 
woolmilkporcCommented:
When it's just for the directory  listing ...
why not use the standard Windows FTP client?
 
0
 
MariaHaltAuthor Commented:
I tried that too...no luck.  ls just doesn't work like one would expect in ftp mode.
0
 
MariaHaltAuthor Commented:
.com worked!  Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.