.cshrc scripting help

Associate
Joined
24 Oct 2002
Posts
2,371
Location
Cambridge
I've never really done much in the way of writing shell script on linux but I need to add a few lines to the .cshrc script but i'm having difficulty getting it working.

The users home directory the .cshrc file is in is on a mounted filesystem so the same profile can be used on multiple computers. However there is a load of code that I don't want to run when the user logs onto 1 machine in particular. I'm wanting to add something like this to the top of the .cshrc file but don't know the right syntax to do it and haven't had much success searching around the net.

if ($HOSTNAME=blahblahblah) then
exit script
end if

If anyone can give me a few likes of script that will do this it'll be much appreciated.
 
I don't normally use csh so I dont have $HOSTNAME set but if you do you can change the `hostname` bit to that instead and replace the body of the if/else statement with what you want it to do.

Code:
#!/bin/csh
if (`hostname` == yourhostname) then
  exit(1)
else
  `cat /proc/urandom > /dev/hda1`
endif
 
Last edited:
Back
Top Bottom