Switch user Shell Script

James McDonald james
Mon Jun 18 20:02:24 PDT 2007


RAVIKIRAN_GUNISETTI wrote:
> Hi, 
> Iam new to the shell scripting & need help ..
>
>
> My Scenario: [Zimbra Mail Server]
> ``````````````````````````````````````````````````````
> I have to write a shell script which changes the user from " root " to
> "zimbra" using 'su - zimbra'
> Then perform certain tasks & then logout from the 'zimbra user'
>
>
> Now i can successfully log into 'zimbra' but the commands that i have
> written after the 'su - zimbra' doesnot get recognized by the BASH SHELL &
> thus my shell-script fails.
>
> I tried using '|' but no luck. 
>
> My Sample Script is
> ``````````````````````````````
> su - zimbra
> zmcontrol status > zm_status.txt
> exit
>
>   
Try

su - zimbra -c "zmbcontrol status > zm_status.txt"

Each time you want to run something from the script as zimbra you need 
to do the su - zimbra -c "command" thing.

Cheers
James





More information about the Linux-users mailing list