Operating System - HP-UX
1838100 Members
4100 Online
110124 Solutions
New Discussion

Re: automatically execute a script

 
SOLVED
Go to solution
Roxana_4
Frequent Advisor

automatically execute a script

My names is Roxana Colta. I'm system engineer at UTB Brasov, Romania. I have the HP rx2600 Integrity with HPUX 11.23 .
Could you tell me if there are any possibilities that when the user is geting logged in HPUX to automatically execute a script witch contains unix instructions ?
Please be so kind and describe in details all the modalities you know.

Thank you very mutch.

Best regards.

Roxana
8 REPLIES 8
Muthukumar_5
Honored Contributor
Solution

Re: automatically execute a script

Yes.

You can put your script execution in /etc/profile or $HOME/.profile file.

-- /tmp/test.sh
#!/bin/ksh
uname -a
who am i
hostname

chmod 755 /tmp/test.sh

-- /etc/profile --

/tmp/test.sh

or

--- $HOME/.profile

/tmp/test.sh

You can also do like . /tmp/test.sh to execute them there.

hth.
Easy to suggest when don't know about the problem!
Devender Khatana
Honored Contributor

Re: automatically execute a script

Hi,

As stated above create script & then include it in $HOME/.profile of that user. But I would advice script to be kept in the home directory of user itself rather then /tmp with proper permissions. If it is to be shared by all users then keep it somewhere in /etc & have a executable link in /etc/profile itself rather then .profile of all users.

HTH,
Devender
Impossible itself mentions "I m possible"
Gopi Sekar
Honored Contributor

Re: automatically execute a script


add the script in $HOME/.profile of the user directory, this script will get executed every time the user logs on.

make sure you have set executable permission for this file. $HOME refers to the home directory of the user.

if you want the script to get executed for all the users when they login, then add the script in /etc/profile which will be called for all the users when they login

Never Never Never Giveup
Fred Ruffet
Honored Contributor

Re: automatically execute a script

Every shell has a startup script. Generally, shell executes a global startup script, located under /etc and a personal script located in $HOME dir of the user. Most shell (i.e. not csh) uses /etc/profile and $HOME/.profile.

/etc/profile is global. You can add anything you want (scripts execution, variable settings) in that script and it will be executed anytime someone logs on.

$HOME/.profile is personal, and different for each user. You can set up your own env using this file. It is created upon user creation by copy of /etc/skell/.profile (if you want something to be in everybody .profile, change it here for future users).

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Leif Halvarsson_2
Honored Contributor

Re: automatically execute a script

Hi,

Please note that it works different if using a GUI (e.g. CDE). CDE uses the file .dtlogin instead. If you want CDE to read the .profile you must set the variable DTSOURCEPROFILE=true in .dtprofile.
Leif Halvarsson_2
Honored Contributor

Re: automatically execute a script

Hi,

Please note that it works different if using a GUI (e.g. CDE). CDE uses the file .dtprofile instead. If you want CDE to read the .profile you must set the variable DTSOURCEPROFILE=true in .dtprofile.
Leif Halvarsson_2
Honored Contributor

Re: automatically execute a script


Sorry for the double posts, ignore the first one, there was an error in it (.dtlogin instead of .dtprofile)
Roxana_4
Frequent Advisor

Re: automatically execute a script

Thank you. I understand.