Topic "possible to get just the last line of an ls?"

Author Message
[View user's profile]

Joined: 2009-01-13
Posts: 3
A server I connect to seems to be blocking my ability to run arbitrary commands via scp. I can only run commands that winscp has built in.

Is it possible to run an ls on the current directory, but only return the last line?

What I used to do was to call a remote command that copied the file to a standard place, and then run a command to download it.
here's the idea.
call cp -p `ls /path/to/file/namewithdate*.TXT|tail -1` /other/path/ID_namewithdate.txt
get -preservetime /other/path/ID_namewithdate.txt c:\NewFilename.txt

But, since I can't run "CALL" anymore, I'm sorta stuck.
I can still "ls," but I can't get winscp to parse the returned stuff to get last line of the directory listing.
Any ideas OTHER than work with the owners of the server?
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26911
Location: Prague, Czechia
See this example script for similar task.
Martin Prikryl

You can post new topics in this forum


What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License