Previous | Table of Contents | Next |
If you have several UNIX systems connected over a network, it is possible to invoke a remote shell to run a command on the remote system and return the output of that command to your screen:
remsh acron who
This shows us who is logged into the remote system called acron. The basic syntax is:
remsh remote-sys unix-command
remote-sys is the name of the remote system where the given unix-command runs. You can pipe text to remsh, which is passed to the unix-command being run on the remote system. Any standard output from unix-command on the remote system is passed to standard output on your system where it can be redirected if desired.
Different types of UNIX systems have different names for this command including: remsh, rsh, rcmd, or remote.
Check the man pages on your system to see which command is correct. Be careful to avoid confusion with the restricted shell command rsh, which is sometimes invoked as /usr/lib/rsh if rsh invokes the remote shell.
Using the remote shell requires setting up /etc/hosts.equiv, which indicates a trust relationship between the two systems. The simplest most trusting setup is to put each system name in the other systems host.equiv file. Usually the same user account is added to both systems. Then a remote command run by that user on one system runs with the same access permissions for that user on the other system. To use this facility for root, /.rhosts must be set up to contain the other system name.
Here is a more complex example that enables us to copy a whole directory tree to the remote system:
cd /sourcedir find . -print | cpio -ocva | remsh remote_sys \( cd /destdir \; cpio -icdum \)
The find command passes a list of files to cpio, which copies them to standard output. This is passed by the remote shell command to the remote system where the files are restored to the desired destination directory. Notice that many of the special characters must be escapedthat is, preceded by a backslashso they are interpreted on the remote system and not on the local system.
In this chapter you have looked at several miscellaneous tools:
A large part of this chapter was spent on the basics of the find command. Peruse the man page on find, and you can see other useful find options for your scripts that I did not cover.
Previous | Table of Contents | Next |