Switch user Shell Script
Net Llama!
netllama
Mon Jun 18 07:24:53 PDT 2007
On Mon, 18 Jun 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
>
> Note: zmcontrol is Zimbra specific & can only be executed through zimbra
> user login.
What you should really be doing is either running this entire thing as hte
zimbra user directly, or create a shell script that does all the work
(after switching to the zimbra user), and call it like this:
su - zimbra -c myscript.sh
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lonni J Friedman netllama at linux-sxs.org
LlamaLand http://netllama.linux-sxs.org
More information about the Linux-users
mailing list