Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

rsh - remote shell

&pagelevel(4)&pagelevel

rsh can be used to execute a command on a remote Unix system.

You can use this command if, for example:

  • you want to determine the contents of a directory on a remote Unix system, or

  • you want to print a file on the remote Unix system.

The rsh command can only be used by users with access authorization on the remote host. In other words, the .rhosts file in the HOME directory of the user ID on the remote Unix system must have an entry containing the name of the local host or a plus character (+) and the user ID. The user ID must have a standard account number for rlogin access. This standard account number can be assigned using the ADD-USER, MODIFY-USER-ATTRIBUTES or ADD-POSIX-USER command.

The rsh command can be used symmetrically by BS2000-POSIX and remote Unix systems.

The files /etc/hosts and /etc/hosts.equiv usually used in Unix systems are not used in POSIX. The assignment of host names to IP addresses is handled via BCAM or DNS.

The command can only be executed if the daemon rshd is active on the local and remote hosts. The daemon rshd is started by inetd.

The actual command interpreter called to execute the command on the remote host is determined by the entry of the user in the /etc/passwd file.

If rsh is executed from a file that is not named rsh, it will use the name of that file as the remote host. In other words, if you create a symbolic link to rsh under the name of the remote host, you can call rsh by simply specifying that host name.

Stop signals interrupt only the rsh process on the local host.

The environment variables of the local host are not passed to the command interpreter on the remote host.


Syntax


rsh  host[  -n ][  -l  login][  -x ][ kommando][ option]

host

The BCAM or DNS name of the remote host on which a Shell command is executed. The name of the remote host must be known to local BCAM or to the DNS server.

Instead of the name of the remote host you can also specify its IP address in IPv4 or IPv6 dot notation. The IP address must be known to BCAM.

IPv4: n.n.n.n

n = 0..255 (decimal)

IPv6: x:x:x:x:x:x:x:x

x = 0..FFFF (hexadecimal)

The alternative presentation methods described in RFC 2373 are permissible for IPv6 dot notation.

-n

Instructs the rsh command to not redirect its standard input to the command on the

remote host. The standard input of rsh is redirected to /dev/null instead.

This is useful, for example, if the output of the rsh command is being piped to a program that is itself reading from standard input (see Example 1).

Note, however, that -n is also required when an rsh command is started in the background.

For example, the call

rsh host dd if=/dev/nrmt0 bs=20b | tar xvpBf -

causes tar to terminate before rsh. The rsh command then tries to write to the broken pipe and competes with the command interpreter for the standard input instead of exiting. The -n option can prevent this from occurring.


This problem only occurs when rsh is located at the start of a pipe and is not reading from standard input. If you want rsh to actually read from standard input, you must not specify the -n option.

For example, if you call the command

tar cf - . | rsh host dd of=/dev/rmt0 obs=20b

with the -n option, rsh will incorrectly read from /dev/null instead of the pipe.


-l login

The user ID (or login name) with which the user has logged on at the remote host. This user ID must be specified if you want to work on the remote host with a different user ID than on the local host.

-x

The rsh command returns the termination status of the remote command if the rsh server on the remote system also supports this feature (BS2000-POSIX, Unix system).

command

The command to be executed on the remote host.

command not specified:
rsh uses rlogin to log on at the remote host.

option

Arguments to be used with the command on the remote host.

Mode of operation

The rsh command transfers

  • its standard input to the command on the remote host

  • the standard output of the command on the remote host to the standard output of the rsh command

  • the standard error of the command on the remote host to the standard error of the rsh command

The interrupt, quit and terminate signals are passed on to the command on the remote host.

The current directory of the started command is set to the HOME directory of the user on the remote host.

Metacharacters (e.g. <, >, &) that have not been escaped are evaluated on the local host. Escaped metacharacters are interpreted on the remote host.

The rsh command exits on completion of the command on the remote host.

Screen-oriented programs such as ced, for example, cannot be activated with the rsh command. The command rlogin must be used instead.

Example 1

The POSIX user john wants to view the contents of the directory /home/john/test on the remote host rainbow. The output is to be displayed on the screen in pages. The user ID john is also present on the remote host rainbow.

$ rsh rainbow -n ls -l /home/john/test | more
total 167232
drwxrwxr-x   2 john 99          1024 Mar 18 09:24 archive
drwxr-xr-x   2 john 99          1024 Apr 14 14:15 de
drwxr-xr-x   2 john 99          1024 Apr 22 08:19 en
 ...
--More--

Example 2

The POSIX user john wants to append the contents of the remote file /home/john/hello_1 on the remote host rainbow to the local file test_1. The user ID john is also present on the remote host rainbow.

$ rsh rainbow cat /home/john/hello_1 >> test_1

Example 3

The POSIX user john wants to append the remote file /home/john/travel_1 to the remote file /home/john/holland. Both files are located on the host rainbow. The user ID john is also present on the host rainbow.

$ rsh rainbow cat /home/john/travel_1 ">>" /home/john/holland

Example 4

The POSIX user john wants to print the remote file /home/emil/test on the host rainbow at that host.
The POSIX user john has been entered in the /home/emil/.rhosts file on the host rainbow.

$ rsh rainbow -l emil lpr /home/emil/test

Example 5

A POSIX user wants to print the local file /home/john/dat on the remote host rainbow.

$ rsh rainbow lpr < /home/john/dat

File

/$HOME/.rhosts

List of host names and user IDs that can log on to the hosts under the listed IDs.

See also

rcp