stat

Retrieves attributes of remote file.

Syntax

stat <file> 

Remarks

Note that, when automating, this command can be used to check file existence.

Advertisements:

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

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.

 
  scriptcommand_stat.txt · Last modified: by martin
 

Search Documentation

This page

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

Associations

Site design by Black Gate