Operating System - HP-UX
1758570 Members
1826 Online
108872 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"