Wednesday, May 12, 2004

UNIX Shell Agents

Check out the following peace of code. It *is* what I think would qualify for a UNIX Shell Agent. You can use UNIX Shell Agents to perform some kinda processing on a number of hosts on your network -- all in pure and simple UNIX shell code. I'll post more shell agent samples in the future. Comments are welcome!

---------- agent.sh --------------


#! /bin/sh

############################################
# UNIX Shell Agents
# by Siddharth Uppal
# agent.sh: Simple Shell Agent sample
############################################
AgentSource="/u/uppals/PlayGround/agent.sh"

NextHost="some.host.com"

echo "I'm currently running at `hostname`"
if [ "`hostname`" != "$NextHost" ]
then
echo "Moving to $NextHost"
rsh $NextHost $AgentSource
else
# We're on NextHost, do something!
echo "Displaying the users logged into $NextHost"
who
fi