This is an old revision of the document!
ls
Lists the contents of specified remote directory.
ls [ <directory> ]/[ <wildcard> ]
Lists the contents of specified remote directory. If directory is not specified, lists working directory. When wildcard1 is specified, it is treated as set of files to list. Otherwise, all files are listed.
Advertisement
Alias: dir
XML log element: ls
Examples
ls *.html ls /home/martin ls
Converting to .NET Assembly
When converting script to .NET Assembly, map ls command to Session.ListDirectory method and print returned RemoteDirectoryInfo in your preferred format.
Parameters mapping: Command parameter directory/wildcard maps to method parameter path. You have to convert relative path to absolute path.
For example, following script snippet:
cd /home/martinp ls
maps to following PowerShell code:
$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) }
Advertisement
Note that this omits inode, owner and group as these are not available in .NET assembly.
- Windows wildcard supports *and?only. It does not support all the features of file masks.Back