Switch user Shell Script

James McDonald james
Mon Jun 18 20:15:19 PDT 2007


James McDonald wrote:
> 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
>
>   
I am a master of the belated post... For some reason I hadn't refreshed 
my mail box and only saw all the replys after I posted ....

Anyway ... you all get an A for awesome technical ability.




More information about the Linux-users mailing list