Previous Topic: del, rm Commands--Delete Files (Funclets)Next Topic: exit, quit Commands--Terminate an AutoShell Session (Cmdlets)


dir, ls Commands--Get File and Directory Information (Funclets)

These commands (funclets) list information about the contents in the specified directory on a local or remote system. You can write the output to a file using the set alternate to command.

They have the following syntax:

{dir|ls} mask [-silent] [-retval] [-l] [-user username] [-pass password] [-key key phrase] [-port portnumber]
mask

Defines a string with a search mask optionally containing an absolute or relative directory specification. The separation character on Windows can be a backslash (\) or a forward slash (/). For UNIX-like systems, it must be a forward slash. For cross-platform script compatibility, only use the forward slash in path specifications.

Search masks use a simplified regular expression syntax that is compatible with DOS wildcard matching:

All other characters are not special characters and match themselves.

Default: ""

-silent

(Optional) Suppresses output to the active output stream.

-retval

(Optional) Creates an array representing the return value. The array contains the file information. Each element consists of a string representing the file name. If argument -l is specified, each element consists of an array containing following items:

-l

(Optional) Use long listing format for output.

-user username

(Optional) Specifies the user name to log in to the remote node. A user name is required for password or public key authentication. If no user name is specified, the user name entered during AutoShell login is used. Unquoted argument tokens are automatically stringified. Prevent automatic quoting for expressions by placing expression code in parentheses.

Default: $$User

-pass password

(Optional) Specifies password to use to log in to the remote node. If no password is specified, the password entered during AutoShell login is used. To enter a hidden password after issuing this command, specify PW_GET() with an optional prompt as argument. Unquoted argument tokens are automatically stringified. Prevent automatic quoting for expressions by placing expression code in parentheses.

Default: $$Pass

-key key

(Optional) Specifies an absolute or relative path to a file containing a private RSA key to use to log in to the remote node. If a private key and a password are specified, AutoShell attempts a public key logon first, and if that fails, a password logon. Unquoted argument tokens are automatically stringified. Prevent automatic quoting for expressions by placing expression code in parentheses. This parameter is only required when creating an SSH session on the fly using public key authentication.

Default: ""

phrase

Specifies the passphrase for a private key. If the key is not encrypted, the phrase is not required. To enter a hidden password after issuing this command, specify PW_GET() with an optional prompt as argument. Unquoted argument tokens are automatically stringified. Prevent automatic quoting for expressions by placing expression code in parentheses.

Default: ""

-port portnumber

(Optional) Port on which to connect to the target system.

Default: SSH standard port 22.

Examples

Get file names of the current directory:

dir

Get file names of directory c:\test:

dir c:/test

Get file names of directory c:\test and c:\test\more as content of the file test.list:

set alternate to test.list
dir c:\test
dir c:\test\more
set alternate to

List the directory contents of c:\temp on the remote server ascli1:

dir ascli1::c:/temp

Get file names of directory c:/test/more as an array for further processing and suppress any output to stdout:

set result disp off
aRet = dir c:/test/more -silent -retval

Get extended information for files of directory c:/test/more as an array for further processing:

aRet = dir c:/test/more -silent -retval -l

See also:

cd, chdir Commands--Change Directory (Cmdlet, Funclet)

pwd Command--Print Name of Working Directory (Cmdlet)

set alternate to Command--Set Alternate Output File (Cmdlet)