Operating System - HP-UX
1820879 Members
3743 Online
109628 Solutions
New Discussion юеВ

Can you bypass .profile or run an alternate one from login: prompt?

 
Bryce Cunningham
Occasional Contributor

Can you bypass .profile or run an alternate one from login: prompt?

I have an urgent business need to automatically run after login verification a different shell command for a user than what there .profile normally does for them. To be perfectly clear -- THIS CANNOT BE LOGIC WITHIN .PROFILE. The reason is that this is a simulated login into HP-UX launched from another server on behalf of a particular user, so it must be run within their username immediately after the username and password verification. This is non-interactive, so it is completely driven by whatever happens in .profile.

If you are familiar with OpenVMS, one solution would be a command switch or option from the 'login:' prompt. In OpenVMS you can bypass the login command file (equivalent functionally to .profile) with a /NOCOMMAND switch typed immediately after the username at the 'Username:' prompt. Example - Username: JOHNDOE /NOCOMMAND. Or, alternatively, Username: JOHNDOE /COMMAND=ALTERNATE. Is there anything like this in HP-UX, a way to determine at login verification what happens immediately after your process is created?

Thanks you!
"Our problems are manmade; therefore they can be solved by man." - JFK
8 REPLIES 8
James R. Ferguson
Acclaimed Contributor

Re: Can you bypass .profile or run an alternate one from login: prompt?

Hi Bryce:

You could construct your own environment (script, for instance) and declare it in lieu of the normal shell program in /etc/passwd.

Often this is done for menu-based scripts where the intent is for the user to login and immediately be placed in a restricted, menu-only environment. Whether or not the script so offered allows shell-out is up to you.

Does this help?

Regards!

...JRF...
G. Vrijhoeven
Honored Contributor

Re: Can you bypass .profile or run an alternate one from login: prompt?

Hi brice,

It depents on how you log in. Reflection or X logins do not run .profile. But i do not think that rthe login process can be changed while you login.
login verifies the account starts a shell (can be changed in passwd )and runs .profile.

hope this will help
Roger Baptiste
Honored Contributor

Re: Can you bypass .profile or run an alternate one from login: prompt?

You have different options to
go about it:

One is to:
Remove the shell of these
user(s) in the /etc/passwd
file and replace it with
the "'executable"" you want
to run. Also, remember to
include this executable in /etc/shells file.

Another one is to:
Let the .profile be there,
but its contents have:

trap "exit" 1 2 3
exec "command"

----

HTH
raj

Take it easy.
Sanjay_6
Honored Contributor

Re: Can you bypass .profile or run an alternate one from login: prompt?

Hi Bryce,

I don't think there is an option in hp to bypass the profile.

The choice for you would be to put an exit in the begining of .profile to exit the execution of the profile or to edit /etc/profile to exit after running /etc/profile (std system profile run for every user before uer .profile) for that particular user. To run a specific profile once logged into the system you can run it using
./user_personal_profile

Hope this helps.

Regds
Craig Rants
Honored Contributor

Re: Can you bypass .profile or run an alternate one from login: prompt?

I agree with James. I have done this before with users who only needed access to an application. We made the application their shell and that way they could not get shell access. You should be able to create a psuedo shell that meets your needs.

C
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Craig Rants
Honored Contributor

Re: Can you bypass .profile or run an alternate one from login: prompt?

I should clarify that the application I mentioned was a TUI type application running in a shell environment.
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Michael Tully
Honored Contributor

Re: Can you bypass .profile or run an alternate one from login: prompt?

Hi,

Replace the entry in the /etc/passwd file
where its states the shell. e.g. /usr/bin/ksh
change to /usr/local/yourprogram. Make sure
that you add this entry to the file /etc/shells.

-Michael
Anyone for a Mutiny ?
Rodney Hills
Honored Contributor

Re: Can you bypass .profile or run an alternate one from login: prompt?

At the login prompt you can enter a space following your login name and give some parameters. For instance I could type-
Login: mylogin nocommand
Password: xxxxxx

Then when ksh runs /etc/profile, enironmental variable L1 will be set to "nocommand". You could test for this and take the appropriate action.

-- Rod Hills
There be dragons...