Operating System - HP-UX
1752282 Members
4709 Online
108786 Solutions
New Discussion

Re: how to know which script is running at switch user event

 
pardeep3dec
Occasional Advisor

how to know which script is running at switch user event

Dear experts,
Help me out how to identify that which .ksh file runs during su - <username>
Because while i am switching as below:-
su - alp
There is script file which shows me some option to start stop application. I am sure this is .ksh file which is showing me the options to do operation with application like start , stop,reboot system, shut down aystem etc.

I am interested to know where is the file and how it is called by hp-ux at the time of 'su' command.
Thank you for the answer.
Regards,
Pardeep
5 REPLIES 5
Patrick Wallek
Honored Contributor

Re: how to know which script is running at switch user event

When doing an 'su - alp' the files that are run will depend on the shell for that user.  If it is sh or ksh then the .kshrc and/or .profile will be run.

That would be the first place I would look.  Those files likely call anything else that runs.

 

The other option is that instead of having /usr/bin/sh as the shell in /etc/passwd, the user may have a custom program or script as its "shell".  If that is the case, then that script / program will run.

 

 

pardeep3dec
Occasional Advisor

Re: how to know which script is running at switch user event

Hi Mr patrick,
I missed actually the command is
su - maint
I saw in .profile and .kshrc but both the file doesn't contain .ksh file related to program.
.kshrc_maint is the file which contain .ksh file calling command but i am not sure, is .kshrc_maint file called after ' su - maint' command.
A little input when i saw passwd file it is showing

maint:vxfrh98zgt2.c:210:201::/runex:/usr/bin/ksh
runex:tvx/9ytvidwc:212:201::/runex:/usr/bin/ksh
Dennis Handly
Acclaimed Contributor

Re: how to know which script is running at switch user event

> kshrc_maint is the file which contain .ksh file calling command but i am not sure, is .kshrc_maint file called after ' su - maint' command.
> maint:vxfrh98zgt2.c:210:201::/runex:/usr/bin/ksh
 
This means you need to look in ~maint/.profile for what happens.  Do you see .kshrc_maint being executed?
pardeep3dec
Occasional Advisor

Re: how to know which script is running at switch user event

I have checked ~maint/.profile but there is no calling related to .khrc_maint

How can i check .kshrc_maint is executeding ?
Thank you for the guidance.
Steven Schweda
Honored Contributor

Re: how to know which script is running at switch user event

> maint:vxfrh98zgt2.c:210:201::/runex:/usr/bin/ksh

   I don't use ksh, so I know nothing, but I'd check the "man" page to
see if it automatically reads any files other than "~/.profile".

> I have checked ~maint/.profile but there is no calling related to
> .khrc_maint

   Ok, but what if that ".profile" (or some other initialization script
fragment) runs something else which runs ".kshrc_maint"?

> How can i check .kshrc_maint is executeding ?

   To see what "~/.profile" is doing, you could add "set -v" near its
beginning.  If it's not obvious, then you might add a command like:
      echo 'some message'
near the beginning of ".kshrc_maint".

   There may be clever, modern methods to trace these things, but
simple, old methods like adding some "echo <message>" commands in
various places should help to locate interesting events.