Run a script on login event


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run a script on login event
# 1  
Old 12-02-2011
Run a script on login event

Hi,

I need to run a script whenever a user logs in to HP-UX unix server.
Please let me know how can i implement this.

I need to run this script on login for all users starting with 'X' ( x110,x112,x13545, etc).

Thanks a lot.
# 2  
Old 12-02-2011
You can put the script to execute on: /etc/profile, because this file is loaded whenever a user logs and it would be something like:
Code:
specialUser=`echo "${USER}" | egrep -ic '^X'`
if [ ${specialUser} -ne 0 ]
then
      # Put your process here!
      echo "User starts with: [X|x]"
fi

I hope it helps!
# 3  
Old 12-02-2011
We implement something in a way to keep /etc/profile relatively close to the supplied original. Based on the primary group, we then call a profile:-
Code:
GROUP=`id -g -n`

if [ -f /usr/local/bin/${GROUP}.start ]
then
  . /usr/local/bin/${GROUP}.start
fi

Using this, you can segragate users. I suppose it wouldn't be too hard to get it to work down a list of secondary groups if that's better, e.g. if you have a dba group and a security group then you might want a user with both to get all the settings for both.


I hope that this helps


Robin
Liverpool/Blackburn
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Simple CEC run command on event script

To cut a long story short I need to implement a CEC server in order to allow my Samsung TV to interact with other peripherals. I plan on using a RPi for this purpose. I have installed CEC-untils and can run the tvservice monitor to look for HDMI events. I now need a simple script that will run... (3 Replies)
Discussion started by: barrydocks
3 Replies

2. Solaris

Login/xterm and run script

Hi - I need to have a script run automatically when I login to my solaris 10 system (running CDE). I stuck this in my .cshrc file: xterm -e /bin/sh -c "/.script-name; exec /bin/sh" When I login, a window comes up and runs the iteractive script-name, and then when the script is done, my... (4 Replies)
Discussion started by: pyroman
4 Replies

3. Linux

How to open a gnome-terminal in specific workspace and run script within it automatically upon login

OK this is a bit messy. I run Fedora with gnome on a compiz desktop, I have a script (userstart) that opens my 'standard' environment for all my machines when I login. userstart flips to a specific workspace and then opens the required applications in that workspace then flips to the next... (2 Replies)
Discussion started by: Bashingaway
2 Replies

4. AIX

How to: Run backup_menu.sh at login for only one user

Hi all, I Hope to find the answer. I am new to aix 5L, I have one oracle 10gR2 database server run on ain 5L so when I start my new Job I find that the operater login oracle user and run the backup_menu.sh, this menu is to make a backup of the database top disk and transfer it to tape,... (3 Replies)
Discussion started by: essamfayez
3 Replies

5. Shell Programming and Scripting

Run script at first login user (only)

Hi all, I would need a script to run only at the first login of a newly created user. And at the first time only. I did some googlework but unfortunatly... I made up it possibly had something to do with the bashrc file. This script is some kind of info for the user ; with the possiblity to... (1 Reply)
Discussion started by: laurens
1 Replies

6. HP-UX

How to run tlremove command without root login

Hi all, Can somebody give me advice on how to run tlremove and tlinstall command without root login. When i try to login to root i get error message as "crt0: ERROR couldn't open dld.sl errno:000000002". This error comes when transition link is removed. so i want to reinstall the link... ... (1 Reply)
Discussion started by: aditya.gaur
1 Replies

7. Solaris

Run fsck from standard login

Hello. I have created a FS /u00/ and created a non-root login under this FS. Also, disabled direct root login. Now is it possible or worth moving this login over to the root partition or allowing mount/umount + fsck from a standard account. As I am not able to run fsck for this FS. How to... (5 Replies)
Discussion started by: panchpan
5 Replies

8. UNIX for Dummies Questions & Answers

run commands before login

What would be the best way to setup for a Linux box to run a few commands before the user logs in? (1 Reply)
Discussion started by: woofie
1 Replies
Login or Register to Ask a Question