rcmd(1) CLIX rcmd(1)
NAME
rcmd - Runs a command on a remote system
SYNOPSIS
rcmd host [-l username] [-n] [command]
FLAGS
host Specifies the remote host to which you want to send the
command. The hostname you provide must be named in your DNS
database (if DNS is running) or the /etc/hosts file.
-l username Specifies a username to use for the home directory on the
remote host. If this flag is not specified, the local
username is used by default.
-n Redirects stdin to /dev/null. This flag is used if there is
no input to the remote command.
command Specifies the command that will execute on the remote host.
If you do not provide a command, you will log on to the
remote host as if you were using rlogin.
DESCRIPTION
The rcmd command connects to the specified host and executes the specified
command, where command is any command, including arguments, that is valid
on the remote host. The input to stdin on the local host is sent to stdin
on the remote host, unless the -n flag is specified. Interrupt, quit, and
terminate signals are propagated to the remote command as well. The rcmd
command normally terminates when the remote command terminates.
If command is omitted, instead of executing a single command, rcmd uses
rlogin to establish a session with the remote host.
Unquoted shell metacharacters are interpreted on the local machine, while
quoted metacharacters are interpreted on the remote machine. Thus the
following command appends remote-file to local-file:
rcmd otherhost cat remote-file >> local-file
Whereas the following command appends remote-file to other-remote-file:
rcmd otherhost cat remote-file ">>" other-remote-file
The rcmd command does not prompt for passwords. The remote username is
assumed to be the same as the local username unless the -l username flag
is specified with the command. If the remote user's login account has a
password, then the user must ensure that either the local hostname is in
2/94 - Intergraph Corporation 1
rcmd(1) CLIX rcmd(1)
the /etc/hosts.equiv file on the remote system, or that there is a fully
qualified name (hostname plus domain name) entry in the .rhosts file in
the remote user's home directory containing the local hostname and
(optionally) the username on the local host.
Hostnames are resolved through the Domain Name System (DNS) or found in
the file /etc/hosts. Each host has one standard name (the first name in
the file), which is long and unambiguous, and, optionally, one or more
aliases.
Since rcmd by default reads stdin, there must be something to read from.
This can be either a controlling terminal, output from a piped command, or
redirection from a file. An example of a controlling terminal would be
running rcmd by itself on a command line, as in the following:
rcmd ingrid ls -ls /usr/bin
If you processed this command in the background (by adding an ampersand
(&) at the end of the command line), rcmd would no longer have control of
the terminal and the read from stdin would hang. Process output would also
be blocked. To avoid this, the -n option is essential whenever rcmd is
placed in shell scripts which will be run in the background or by cron.
EXAMPLES
1. To display a listing of your home directory on remote host sam, enter:
rcmd sam ls
2. To display a listing of the home directory for username joe on remote
host sam, enter:
rcmd sam -l joe ls
3. To issue a remote command and redirect stdin for rcmd to dev/null,
enter:
rcmd sam -n ls
4. To begin a remote session with host sam using rcmd (rcmd uses rlogin),
enter:
rcmd sam
FILES
2 Intergraph Corporation - 2/94
rcmd(1) CLIX rcmd(1)
/etc/hosts
Hostname database.
/etc/hosts.equiv
Host equivalency name database.
/etc/resolv.conf
DNS client configuration file. DNS is the preferred method for
address resolution.
.rhosts
Remote user access list.
NOTES
Interactive commands (such as vi) cannot be run using rcmd. Instead, use
rlogin to run interactive commands.
CAUTIONS
A stop signal stops only the local rcmd process.
DIAGNOSTICS
rcmd: shell/tcp: unknown service
The /etc/services file on the local host needs updating.
rcmd: cannot make connection with RSH server
There is a problem connecting to the remote host. Try again. If
the problem persists, contact your system manager.
A usage message is displayed if an undefined flag is specified on the
command line. Other error messages are displayed with the perror()
function.
EXIT VALUES
The rcmd command exits with a value of 0 if successful. If unsuccessful,
it exits with a nonzero value.
RELATED INFORMATION
Commands: rlogin(1), rshd(8)
Files: hosts(4), hosts.equiv(4), .rhosts(4)
2/94 - Intergraph Corporation 3