stat command
Retrieves attributes of remote file.
Advertisement
Syntax
stat <file>
Remarks
Note that, when automating, this command can be used to check file existence.
XML log element: stat
Examples
stat /home/martin/index.html
Converting to .NET Assembly
When converting script to .NET Assembly, map stat command to Session.GetFileInfo method and print returned RemoteFileInfo in your preferred format. When using stat solely to check for file existence, map it to Session.FileExists.
Parameters mapping: Command parameter file maps to methods parameter path. You have to convert relative paths to absolute paths.
For example, following script snippet:
cd /home/martinp/public_html stat index.html
Advertisement
maps to following PowerShell code:
$fileinfo = $session.GetFileInfo("/home/martinp/public_html/index.html") 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)
Note that this omits inode, owner and group as these are not available in .NET assembly.