Differences

This shows you the differences between the selected revisions of the page.

scriptcommand_ls 2011-11-10 scriptcommand_ls 2020-10-16 (current)
Line 1: Line 1:
-====== ls ====== +====== ls command ====== 
-Lists the contents of specified directory.+Lists the contents of specified remote directory. 
 + 
 +===== Syntax ===== 
  ls [ <directory> ]/[ <wildcard> ]   ls [ <directory> ]/[ <wildcard> ]
-Lists the contents of specified remote directory. If ''directory'' is not specified, lists working directory. When ''wildcard'' ((Windows wildcard supports ''*'' and ''?'' only. It does not support all the features of [[file_mask|file masks]].)) is specified, it is treated as set of files to list. Otherwise, all files are listed.+===== [[remarks]] Remarks ===== 
 + 
 +Lists the contents of specified remote directory. If ''directory'' is not specified, lists working directory. When ''[[file_mask|wildcard]]'' ((Only single include mask can be specified.)) is specified, it is treated as set of files to list. Otherwise, all files are listed.
Alias: ''dir'' Alias: ''dir''
 +
 +Effective [[scriptcommand_option|options]]: ''[[scriptcommand_option#failonnomatch|failonnomatch]]''
XML log element: ''[[logging_xml#ls|ls]]'' XML log element: ''[[logging_xml#ls|ls]]''
-===== Examples =====+===== [[examples]] Examples =====
<code winscp> <code winscp>
ls *.html ls *.html
 +</code>
 +<code winscp>
ls /home/martin ls /home/martin
 +</code>
 +<code winscp>
ls ls
</code> </code>
 +<code winscp>
 +ls /home/martin/*.html
 +</code>
 +
 +===== [[net]] Converting to .NET Assembly =====
 +When [[library_from_script|converting script to .NET Assembly]], map ''ls'' command to ''[[library_session_listdirectory|Session.ListDirectory]]'' method and print returned ''[[library_remotedirectoryinfo|RemoteDirectoryInfo]]'' in your preferred format.
 +
 +Parameters mapping: Command parameter ''directory/wildcard'' maps to method parameter ''path''. You have to [[library_from_script#paths|convert relative path to absolute path]].
 +
 +For example, following script snippet:
 +
 +<code winscp>
 +cd /home/martinp
 +ls
 +</code>
 +
 +maps to following [[library_powershell|PowerShell]] code:
 +
 +<code powershell>
 +$directory = $session.ListDirectory("/home/martinp")
 +
 +foreach ($fileInfo in $directory.Files)
 +{
 +    Write-Host ("{0}{1} {2,9} {3,-12:MMM dd HH:mm:ss yyyy} {4}" -f
 +        $fileInfo.FileType, $fileInfo.FilePermissions, $fileInfo.Length,
 +        $fileInfo.LastWriteTime, $fileInfo.Name)
 +}
 +</code>
 +
 +Note that this omits inode, owner and group as these are not available in .NET assembly.

Last modified: by martin