Executing a script at startup

Hi,

I want a script to execute as soon as a user logs in(instead of directing to his home directory). i know that i have to mention the path of script in the user's .profile to execute this, but not sure where and what to edit. I just tried and was unsuccesful.

Kindly provide the code that i have to add/edit in the .profile of that particular user.

Thanks in Advance!!

Sridhar

What solution u have mention is perfectly valid, thats the way it should be done.
Please give a brief idea about what have u done and how do u consider failed

please make sure that the .profile is being source while users login because
different shells expects files with different name
like .bashrc , .tcshrc , .login , ~.profile, etc and there are lots of other files
so you should be sure which is ur shell and which file is being sourced when a shell is created

Rakesh UV

Hi rakesh! Thanks for the reply.
I just added ./<scriptname> at the end of .profile and its working
But the script is not giving the output that i wanted.

My script is:
#! /bin/sh
main ()
{
tput clear
echo "\t********* WELCOME ********* \n"
echo "\t\t\t 1.top\n"
echo "\t\t\t 2.bdf\n"
echo "\t\t\t x.exit\n"
echo "\t**************************** \n"
echo "\t Enter your choice: \c"
read input
case $input in
1) /usr/bin/top ;;
2) /usr/bin/bdf ;;
*) exit ;;
esac
}
while (true)
do
main
done

What i am trying here, is to get the output of top and bdf. I am getting it but the output of top, i have to interrupt(ctrl+c) to proceed. if i give exit, it is exiting and coming to the prompt whereas i want to get exited from the server completely.

Kindly provide the solution for this...

Thanks !!

(a) you need a trap handler to catch any signals that you don't want to kill the shell script

(b) in your login, use "exec" to run your script so that it is the direct child of the login process, so when you exit, you get logged out

Hi Porter, Thankx for the reply.

Can you be more specific by giving the code pls.

Thanks !!