NSH cheat sheet
This topic provides examples of frequently used NSH commands and script elements that can help you get started with writing NSH scripts.
Frequently used NSH commands
The following table lists few examples of NSH commands and their results. Note that because NSH is based on ZSH, you can find some helpful information by searching the web for ZSH guides (for example http://zsh.sourceforge.net/Guide/).
To take this action | Use this command |
---|---|
Connect to a remote server. |
|
List directory contents on one or many remote machines. |
|
Take actions on a remote file. |
|
Copy one or more file or directories from one machine to another. |
|
Compare a file that exists on multiple hosts |
|
Use
|
|
Convert CSV output to XML using pipe |
|
Remotely execute a command that lives locally on the target server. |
|
Execute a command against many servers. |
|
Verify a process exists across many servers. |
|
Execute an NSH script across many servers |
|
Verify the RSCD agent version, mapping, and license status. |
|
View RSCD agent logfile contents. |
|
Execute a WMIC command on a remote Windows server. |
Examples:
|
To view summarized descriptions of commands and utilities, see the alphabetized table in Summarized descriptions of commands.
NSH scripting elements
The following table provides descriptions and examples of commonly used elements within an NSH Script. It provides information on basic scripting elements such as checking if a file or directory exists, creating a for loop, creating an if else condition, and so on.
To do this | Use this syntax | Examples / Comments |
---|---|---|
Identify the script as an NSH script |
| This should be the first line of an NSH script when run on a UNIX/Linux host to identify it as NSH. |
Check to see if a file exists |
Note: To see if a file does not exist, use an exclamation mark as in the following command:
| (From the command line)
|
Check to see if a directory exists |
Note: To see if a directory does not exist, use an exclamation mark as in the following command:
| (From the command line)
|
Loop through a list, performing the same actions on each item |
Another method for looping through a list, performing the same actions on each item. foreach X in $X..{..} |
|
Check conditions and perform actions depending on results. |
|
|
Miscellaneous Tips and Tricks
The following table lists various tips and tricks for using NSH:
To do this | Use this syntax | Examples / Comments |
---|---|---|
Execute a command in a remote path on a server | -D //<server>/<directory> |
|
Reference the host that NSH was launched from | //@ |
|
Disconnect NSH from a system | disconnect <server> | To cd back to the system running NSH and closes the NSH connection to <server> instead of letting it idle out: |
Comments