Results 1 to 1 of 1
Hi friends,
I am beginner in shell scripting. I have written a simple script which tracks a user and send a email to me when the particular user logs in.
...
- 12-06-2007 #1Just Joined!
- Join Date
- Nov 2007
- Posts
- 8
Strange assignment error..Please help
Hi friends,
I am beginner in shell scripting. I have written a simple script which tracks a user and send a email to me when the particular user logs in.
It is really strange that the script was working fine till evening and when now when I am running it again I am getiing the following error
badUser=lab424: Command not found.
temporary=/tmp/temp1: Command not found.
stableFile=/var/preserve/glopes.txt: Command not found.
badUser: Undefined variable.
below is my code
#!/bin/sh
badUser=lab424 //////////Errored line
## temp file
temporary=/tmp/temp1 ////////errore line
## file which will store the information about the logged in user
stableFile=/var/preserve/glopes.txt
## this command will tell if the user has logged in.
last | grep $badUser > /dev/null
## if baduser found in the log file and if its for the first time then send a mail.
if [ $? -eq 0 ];then
echo $badUser > $temporary
grep -s $badUser $stableFile
tempVal=$?
## if entry for the user exist in the stable file then do not send a mail and exit.
if [ $tempVal -eq 0 ];then
echo "No mail"
exit 2
fi
echo "Sending email to the System Administrator"
## if the name does not exist then send a mail and add the name to a file
mailx -s "Evil user lab424 just logged in to hydra" glopes@clemson.edu , jayh@clemson.edu <<-EOT $
EOT
## add the bad user entry to the stable file
grep $badUser $temporary >> $stableFile
# deleting thee temporay files generated
rm $temporary
fi
Kindly help me with this!


Reply With Quote