Thanks you Carols. Let me work on it and get back if i have any other
queries.

On Mon, Jan 9, 2017 at 2:56 PM, Carlos García <
[email protected]> wrote:

> Hi santosh,
>
> can you use sudo on the target host? I think it’s the easiest way:
>
> from fabric.api import sudo
>
> sudo('id', user='oracle')
> sudo('whoami', user='oracle')
>
> If not, you should run:
>
> from fabric.api import run
>
> run('su - oracle -c id')
> run('su - oracle -c whoami')
>
> To ease its usage you can create a context manager, similar to prefix()
> <http://docs.fabfile.org/en/1.13/api/core/context_managers.html#fabric.context_managers.prefix>,
> but you will have to handle the way to pass the oracle password.
>
> Regards
>
> 2017-01-09 9:06 GMT+01:00 santosh kumar <[email protected]>:
>
> All,
>>
>> I have a requirement where i need to do the following.
>>
>> #su - oracle
>> once logged in as user oracle need to run some commands from there
>> $ id
>> $ whoami
>>
>> so i can achieve this in shell in this formate
>>
>> ssh <hostname>  'su - oracle' <<EOF
>> id
>> whoami
>> EOF
>>
>> Please do let me know how can i achieve this on multiple nodes.
>>
>> Thanks,
>> santosh D
>>
>> _______________________________________________
>> Fab-user mailing list
>> [email protected]
>> https://lists.nongnu.org/mailman/listinfo/fab-user
>>
> ​
>
_______________________________________________
Fab-user mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to