Open Computing ``Hands-On'': ``Answers to Unix'' Column: August 94

Doing remote computing by issuing commands through electronic mail

By Ray Swartz

Alberto Ferrari is looking for a way to run commands on a system that he can't log into. What's more, he needs to do it from different systems. The solution involves a mail filter ASCII characters, it must be run through uuencode before you can e-mail it. The cmd.filter script, is shown in Part A of the Listing. After it performs all the protocol verification, it puts command lines in a temporary file, calls the shell to run them, and then mails the output to the listed receiver (lines 33-35).

The chkcode program (Part B) generates encryption keys. If you use the -l option, it prints a list of encryption keys on the standard output. The number you want listed is placed after the - l option on the command line. If chkcode is called without arguments, it generates the current encryption key based on a counter kept in a file.

Some setup is required for these programs. First, in cmd.filter you need to assign the path name of the chkcode executable file to the variable CHKCODE (Part A, line 2). Note that it must be an absolute path name. Second, in chkcode you must change the define term ONETIMEPADFILE (line 7) to be the absolute path name you want to use for the counter file. You must initialize this file with a starting value (I recommend ``1'') before this system will work. Next, you should redefine the random-number generator's starting seed. Because I have published the one in chkcode.c, it is best to pick another one (Part B, line 8). Choose any number between one and four billion.

You must also set up a .forward file in the home directory of the account that will receive the execution messages. The .forward file should contain two entries: this account's name preceded by a backslash and a pipe command to the cmd.filter script. Part C shows the .forward file I used while testing this application for account ray.

The cmd.filter program relies on the crypt command, which may be missing from your system. If it is, you can find other encryption programs on the Internet. Another solution is the simple encryption technique of using exclusive OR operations. An example is the mailcrypt program shown in my June 1994 column.

Part D shows the steps required to prepare a command file for insertion into an e-mail message.

One important point about preparing your mail message. When a file is encoded with uuencode, you have to list the file name where uudecode is to place the decoded file. Because a daemon will run cmd.filter, you have to know the directory where uudecode will put the decoded script. Thus, you need to use an absolute path name when you encode the script file before mailing it. In Part D, I chose to put the script file in my home directory.


Last Modified: