Switch user Shell Script
David Bandel
david.bandel
Mon Jun 18 07:33:15 PDT 2007
On 6/18/07, RAVIKIRAN_GUNISETTI <gunisetti at gmail.com> 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
above is being run by root.
> exit
you're confused. you cannot do this. to run another script as the
user zimbra, create the script with command zimbra will run, then us
su's (or even better, sudo's -c option with the script as an argument.
Note: if you have to provide arguments to the script, you'll have to
quote the command or escape the spaces.
>
> Note: zmcontrol is Zimbra specific & can only be executed through zimbra
> user login.
su - zimbra -c "zmcontrol status >zm_status.txt"
>
> Please help me with this script.
>
> Thanks
> Ravi.
>
>
Ciao,
David A. Bandel
--
Focus on the dream, not the competition.
- Nemesis Air Racing Team motto
More information about the Linux-users
mailing list