fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] How to switch to a account and run some commands.


From: santosh kumar
Subject: Re: [Fab-user] How to switch to a account and run some commands.
Date: Mon, 9 Jan 2017 15:21:18 +0530

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 <address@hidden> 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(), but you will have to handle the way to pass the oracle password.

Regards

2017-01-09 9:06 GMT+01:00 santosh kumar <address@hidden>:

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
address@hidden
https://lists.nongnu.org/mailman/listinfo/fab-user



reply via email to

[Prev in Thread] Current Thread [Next in Thread]