Operating System - HP-UX
1755684 Members
3755 Online
108837 Solutions
New Discussion

changing user and performing activities in new session in Shell Script

 
srikant_sahoo
New Member

changing user and performing activities in new session in Shell Script

Hi All, I am writing a shell script where in a condition the script will change the user like su - xxx and then it has to execute some commands/scripts and should stay login to that user/session for user interaction. Once user enter exit it should exit from that session and should return to script.

I have tried using su - xxx -c "commands" but it terminates the session after executing the commands. I want to stay on that session after execution of the commands, user should exit manually (type exit) to close that session and return to script.

Any hint will do..

Thanks in advance....for you suggestion..
1 REPLY 1
Laurent Menase
Honored Contributor

Re: changing user and performing activities in new session in Shell Script

why not
su - xxx -c "commands ; exec sh"