Executing a script at startup

Thread Tools Search this Thread
Operating Systems HP-UX Executing a script at startup
# 1  
Old 12-20-2007
Executing a script at startup


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!!

# 2  
Old 12-21-2007
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
# 3  
Old 12-21-2007
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 ;;
while (true)

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 !!
# 4  
Old 12-21-2007
(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
# 5  
Old 12-21-2007
Hi Porter, Thankx for the reply.

Can you be more specific by giving the code pls.

Thanks !!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Startup script

I can't quite find a clear answer on how to properly write a start up script. Does anybody have any ideas?? (3 Replies)
Discussion started by: Huitzilopochtli
3 Replies

2. Shell Programming and Scripting

Startup script problem

The attached file is a copy of my rc.local. The rc.local script appears to execute as the tightvncserver gets started. However the nodemon process does not start. The element nodemon is a symlink to nodemon and the path is correct. I have a little start script located in the... (3 Replies)
Discussion started by: barrygordon
3 Replies

3. Shell Programming and Scripting

Apache tomcat startup script not booting at startup.

I copied the script from an AskUbuntu post - #!/bin/bash ### BEGIN INIT INFO # Provides: tomcat7 # Required-Start: $network # Required-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/Stop Tomcat server ### END INIT INFO ... (14 Replies)
Discussion started by: Hijanoqu
14 Replies

4. AIX

startup script

Hi I need the below script to be started whenever I reboot my aix server ? #cat cdbegin /cdirect/cdunix/ndm/bin/cdpmgr -i /cdirect/cdunix/ndm/cfg/cbspsdb01/initparm.cfg Please suggest how to add this to the startup ? (2 Replies)
Discussion started by: samsungsamsung
2 Replies

5. UNIX for Dummies Questions & Answers

Startup Script Somewhere ?

Hello there! I need help. Everytime I login to my ssh, i see this: -bash: .export: command not found -bash: .export: command not found -bash: .export: command not found -bash: .export: command not found any help ? thanks (0 Replies)
Discussion started by: fbauto1
0 Replies

6. Shell Programming and Scripting

Executing a command at startup

Hey all, How do I execute a file at startup automatically. From what I've read is that I need to put it into my .bashrc file. I'm not sure where to go from there. Can I just type commands into that and they'll run next time I restart my server? Right now I have added these lines: cd... (2 Replies)
Discussion started by: NathanWarden
2 Replies

7. SuSE

Executing set of sh files at system startup

Hi Everybody I am totally new to Linux. We are using Suse Linux version 9. Currently we have 4 to 5 shell scripts which needs to be executed manually by the users.I want these scripts to be run automatically when system starts...something like system startup service. When system is... (1 Reply)
Discussion started by: appleforme1415
1 Replies

8. Shell Programming and Scripting

Startup script

New in Unix, I am adding a line "route add 57.14.y.y 57.14.x.x" every day after rebooting the system. Where can I add the line so during boot up (the system is re-started every day by design (???) the line is executed? (I tried the /etc/rc2.d/S90 but for some reason the line needs to be added... (2 Replies)
Discussion started by: texaspanama
2 Replies

9. AIX

Not executing during startup

I have a command in my iniitab as follows: dsmc:2a:once:/usr/tivoli/tsm/client/ba/bin/dsmc sched > /dev/null 2>&1 But the command doe not appear to execute during a system boot. Not sure why. I am running AIX 5.1 Thanks for the help Mike (2 Replies)
Discussion started by: mhenryj
2 Replies
Login or Register to Ask a Question