Re: [Ssh-sftp-perl-users] About sftp->ls method
Brought to you by:
dbrobins
From: Heiko J. <ja...@hb...> - 2008-07-07 12:19:58
|
Am Montag, den 07.07.2008, 17:29 +0530 schrieb Rajnikant: > > I'm using sftp->ls method to see files on remote location. Following > files are present on remote location: > 5.txt, 4.txt, 3.txt, 2.txt, 1.txt > > Is there possibility that I'll get sftp->ls out put as > 5.txt > 4.txt > -- > -- > 1.txt > > Can I have sorted sftp->ls out put? Out put I want is: > 1.txt > -- > -- > 4.txt > 5.txt As far as I know, $sftp->ls() (where $sftp IS_A Net::SFTP object) returns a list of hash references and there are no options of pre-sorting that list. But no one stops you from iterating over the list, extracting the names and sorting them in any way you like. So the answer to your questions is "yes" - but the way to get there is possibly not as convenient as you'd hoped ;-) Heiko PS: Another option would be to use do_opendir($path) and then use a readdir-loop directly on the dir handle, fetching all filenames and sorting them afterwards. PPS: Yet another method: Use Net::SSH2, execute a shell command ("ls" with the necessary switches) and capture and parse the output. |