开发者

Capistrano :shell example

I'm currently using Capistrano to deploy my web application which works like a charm.

In my new project I must execute a command from sudo /bin/bash shell.

Is it possible for Capistrano to login to the machine as user X, run sudo /bin/bash开发者_开发技巧, enter the password and then execute a command in the sudo shell? If yes, could you please provived me with an example.

With regards

jakob


Is there a specific reason you need to be in a root shell rather than executing the command with sudo? If executing a command with sudo, you can simply sudo 'command' instead of run 'command'.

I did a little experimentation to try to get a root shell with capistrano without logging into the server directly as root, and wasn't able to make much progress.

If running with sudo won't work, please update your question to let us know why and maybe we can help you find a workaround for it.

Update:

After playing around a little more, I found that you can execute an individual command (or string of commands) in a root shell by doing something like sudo '/bin/bash -c "whoami"'. It's getting an interactive root shell that's tricky.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜