Vagrant Ssh With Multiple Arguments
I am having problems executing multiple commands with vagrant ssh. In order to run some tests in vagrant environment I execute following commands: vagrant ssh app sudo su deploy c
Solution 1:
you can do it all in a single command:
vagrant ssh app ---t 'sudo -u deploy /some/dir/for/test/env/bin/python /some/dir/for/test/env/manage.py test'
here you can avoid the useless su
call by giving an argument to sudo
so it runs a command as the given user, using the -u
argument. Then the bin/activate
command is only changing the environment, so the python you're calling thereafter is the one from env/bin/python
, so you can directly call it using its full path.
And for your knowledge, if you want to chain two commands separated by ;
in a single sudo call, you shall spawn a shell in your sudo command, i.e.: sudo sh -c "run this; run that"
.
Post a Comment for "Vagrant Ssh With Multiple Arguments"