9. RSH: Issuing Commands on a Remote Host

Introduction

RSH is the Berkeley R Command utility you can use to execute a single command on a remote host without logging in. This chapter is a summary of using the RSH command.

Before you use RSH, make sure your host and/or username is registered in the remote system's ~/.rhosts file (if UNIX) or SYS$LOGIN:.RHOSTS file (if OpenVMS) . See the TCPware Management Guide, Chapter 16, Managing R Commands, for details on host equivalence files.

 

 

 

 


 

RSH

Executes a single command on a remote host. The remote host must provide command execution service.

When the command completes execution on the remote host, the RSH command exits and closes the connection; you return to your local working environment.

RSH writes any output from the command to SYS$OUTPUT; it writes any error from the command to SYS$ERROR, unless overridden with the /OUTPUT or /ERROR qualifier.

Some servers (such as UNIX servers) send output with only line feeds for screen display. To satisfy OpenVMS screen displays, RSH inserts a carriage return by default before each line feed before sending the output to the terminal. If your screen display requires only a line feed, use the /RAW qualifier to bypass the default.

If you need to preserve case for any of the command elements, enclose each in quotes, since RSH lowercases unquoted text strings. Include a pair of quotes for each redirection of the command. If you are redirecting a command through one remote host to have it executed on a third, each host in turn strips off a pair of quotes after interpreting the command. In this case, you may need three pairs of quotes around the command element to preserve case.

 

Format

RSH host command

 

Parameters

 

host

Name or internet address of the host you want to execute the command on. Can be a domain-style name or an IP address.

 

command

Name of the command or command string to execute on the remote host.

 

Qualifiers

 

/ERROR=file

File or device to which to direct error messages from the remote command. The default is
/ERROR=SYS$ERROR. (See also the /SYSERROR qualifier.)

 

/LOG=file

Logs a copy of the output to the specified file. Output continues to be directed to SYS$OUTPUT while it is being recorded in the log file. Not valid with /SYSERROR. The default is no logging.

 

/OUTPUT=file

Output file or device to which to direct output from the command. The default is /OUTPUT=SYS$OUTPUT.

 

/PASSWORD=remote-password

Password for the remote account. Use together with the /USER qualifier. The password is sent across the network as plain text.

 

/RAW
/NORAW

Prevents an extra carriage return from being inserted for screen display. Specifying /NORAW, the default, or omitting the qualifier places a carriage return before a line feed character before the line is written to the terminal.

 

/SYSERROR

Same as the /ERROR qualifier except that it sends messages to the NLA0 device.

 

/TRUNCATE[=n]

Truncates the local OpenVMS username to the specified n length. The n value must be greater than zero or the command aborts with an error. The default is eight characters.

If the local username is also the remote username (if you omit the /USER qualifier), TCPware also truncates the remote username to the indicated length. However, it never truncates a remote username specified explicitly with the /USER qualifier.

 

/USER=remote-username

Remote host's username that is different from the username with which you are currently logged in to the local host. TCPware never truncates an explicitly specified remote username (see the /TRUNCATE qualifier). remote-username is converted to lowercase unless you enclose it in quotes.

 

Examples

1. This command opens a connection to host IRIS and displays the name of your current working directory:

$ rsh iris pwd

 

2. This command opens a connection to host IRIS for username "Smith" and displays the name of the working directory for "Smith":

$ rsh iris /user="Smith" pwd

The quotes around Smith are necessary because the name contains a mixture of upper- and lowercase characters that you would want to preserve in sending the command. Without the quotes, the name converts to lowercase and may not match the username on the remote host.

 

3, This command opens a connection to host IRIS and displays the name of your working directory in a "raw" state on a terminal that requires only line feeds to display the information:

$ rsh iris /raw pwd

 

4. This command executes a pwd command on ROSES as sent through VIOLET.

$ rsh violet /user=system /password=plastic -
_$ rsh roses /user=root/password="""TCPware""" pwd

The TCPware password is triple-quoted to preserve case through the transaction. The system strips off the first pair of quotes and executes rsh roses /user=root/pass=""TCPware"". VIOLET strips off the second set of quotes and executes rsh roses /user=root/pass="TCPware". ROSES strips off the third and executes pwd. In each case, the password string is interpreted literally.