help for newbie writing shell scripts

Hi, I have just started a Systems Programming course and am required to write a c shell script as part of it.

I have little to no clue about unix.

The spec states that the script can be run only once on each host by a user, but the script can be run on different hosts by the one user.

How would I go about determining whether the script is running on the host?? and how do I activate the script on a remote host, I tried rsh hostname scriptname, but got some type of protocol error, the script relies mainly on the who command.

all help appreciated...


This post is slightly unclear. However, it is common to use rsh (ssh is prefered to execute commands on remote boxes) rsh -l <username> <host> <script>
rsh -l test /usr/src/

sorry about being unclear.

I have tracked the problem down to this:

in a shell script, what command will create an empty file?

how can I then test if this file exists and execute a statement conditionally?
if fileexists

also additional questions:

how can I interrupt a background process without resorting to the process table and kill command?

how can I ensure the (infinitely running) shell script exits when I logout, for e.g if I had the script running as
a background process with output redirected to file, it will continue to run, I need to stop this from happening, and ensure that the same code that handles the interrupt is executed whenever I logout.

thanks very much for any help.