Link to home
Start Free TrialLog in
Avatar of MariaHalt
MariaHaltFlag for United States of America

asked on

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

Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Omit the redirection operator. ls in this context takes only one parameter - the name of a local output file.
Avatar of MariaHalt

ASKER

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.

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
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.
When it's just for the directory  listing ...
why not use the standard Windows FTP client?
 
I tried that too...no luck.  ls just doesn't work like one would expect in ftp mode.
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
.com worked!  Thanks.