rsh(1) rsh(1)
NAME
rsh - execute shell commands at a remote host (remote shell)
SYNOPSIS
rsh hostname[ -x][ -n][ -l login][ command][ args]
DESCRIPTION
The rsh command allows you to execute a command at a remote host.
You can use this command, for example, if you
- want to obtain information about the contents of a directory on a
remote host.
- want to print a file on a remote host.
This command can only be used if you have access permission on the
remote host. You have access permission if
- either the name of your local host or a plus sign and the login
name you are working under have been entered in the .rhosts file in
the home directory for the login used on remote host or
- the login name that you are using at the local host also exists on
the remote host, and your local host has been entered in the
/etc/hosts.equiv file on the remote host.
This command can only be executed if the rshd daemon is active on the
local host and on the remote host. The rshd(1M) daemon is activated by
inetd(1M).
The type of shell called to execute the remote command is determined
by the user's entry in the /etc/passwd file on the remote system.
If the name of the file from which rsh is executed is anything other
than rsh, rsh uses this name as the name of the remote host. This
allows you to create a symbolic link to rsh in the name of a remote
host and then run rsh by simply specifying this host name.
Stop signals stop the local rsh process only.
The current local environment variables are not passed to the remote
shell.
Page 1 Reliant UNIX 5.44 Printed 11/98
rsh(1) rsh(1)
OPTIONS
hostname
Name of the remote host at which a shell command is to be exe-
cuted.
The name of the remote host must be contained in the /etc/hosts
file and/or the Internet domain name database. Each host has one
official name (the first name in the database entry) and option-
ally one or more aliases. Any of these names may be used.
-x is specified if the rsh command is to return the end status of
the remote command as its own end status.
-n is specified if you do not want the rsh command to direct its
standard input to the remote command. The standard input of rsh
is then redirected to /dev/null.
This is helpful, for example, if the output from the rsh command
is piped to a program which itself reads from standard input (see
Example 1).
-n is also required if an rsh command is invoked in the back-
ground.
For example, the command
rsh host dd if=/dev/nrmt0 bs=20b | tar xvpBf -
will cause tar to terminate before rsh. rsh then tries to write
into the "broken pipe" and, instead of terminating properly, com-
petes with the command interpreter for its standard input. Invok-
ing rsh with the -n option avoids such incidents.
Caution:
This problem occurs only when rsh is at the beginning of a
pipeline and is not reading standard input. The -n option
must not be used if rsh actually needs to read standard
input. For example, if the command
tar cf - . | rsh host dd of=/dev/rmt0 obs=20b
were called with the -n option, rsh would incorrectly read
from /dev/null instead of reading from the pipe.
-l login
Login name under which you want to log in at the remote host. You
must use this option if the login name under which you are work-
ing at the local host differs from the one at the remote host.
Page 2 Reliant UNIX 5.44 Printed 11/98
rsh(1) rsh(1)
command
The Reliant UNIX command that is to be executed at the remote
host.
command not specified:
If you omit command, rsh logs you in on the remote host using
rlogin.
args Arguments to be used with the command at the remote host.
Functionality
The rsh command copies
- its standard input to the remote command,
- the standard output of the remote command to its standard output,
and
- the standard error of the remote command to its standard error.
Interrupt, quit and terminate signals are propagated to the remote
command.
The current directory of the invoked command is set to the HOME direc-
tory of the remote user.
Shell metacharacters which are not escaped (e.g. <, >, &) are inter-
preted on the local host, while escaped metacharacters are interpreted
on the remote host.
The rsh command terminates when the remote command does.
Screen-oriented programs such as ced cannot be run with the rsh com-
mand. rlogin must be used for this purpose.
Page 3 Reliant UNIX 5.44 Printed 11/98
rsh(1) rsh(1)
EXAMPLES
Example 1
User john wants to look at the contents of the directory
/home/john/test at the remote host boston. Output to the terminal is
to be displayed one screen at a time. The login name john also exists
on the remote host boston.
$ rsh boston -n ls -l /home/john/test | more
total 4932
drwxr-xr-x 2 john dx 512 Mar 07 1996 hello
-rw-r--r-- 1 john dx 1515 Nov 14 1995 hello1
-rw-r--r-- 1 john dx 5865 Sep 12 10:08 test
-rwxr-xr-x 1 john 1026 37 Dec 06 1994 test.1
.
.
.
-- More --
Example 2
User john would like to append the contents of the remote file
/home/john/hello1 on the remote host boston to the local file test1.
The login name john also exists on the remote host boston.
$ rsh boston cat /home/john/hello1 >> test1
Page 4 Reliant UNIX 5.44 Printed 11/98
rsh(1) rsh(1)
Example 3
User john would like to append the remote file /home/john/travel1 to
the remote file /home/john/canada. Both files are located on the host
boston. The login name john also exists on the host boston.
$ rsh boston cat /home/john/travel1 ">>" /home/john/canada
Example 4
You would like to print the remote file /usr/emily/test located on the
host boston at that remote host. The login name emily is available to
you on the host boston.
$ rsh boston -l emily lpr /home/emily/test
Example 5
You would like to print out the local file /home/john/file at the
remote host boston.
$ rsh boston lpr < /home/john/file
FILES
/etc/hosts.equiv
List of host names; users with the same login name on both the
local and remote host may access the local host from any of the
remote hosts listed in this file.
/$HOME/.rhosts
List of host name/login name combinations identifying users with
permission to log in under your login name. List of host
name/login name combinations identifying users with permission to
log in under your login name.
SEE ALSO
rlogin(1), vi(1), named(1M), hosts(4), hosts.equiv(4).
Page 5 Reliant UNIX 5.44 Printed 11/98