David
David

Reputation: 2241

How to run a script from the host inside a vagrant guest in a single step?

Currently it takes 3 steps to run the script I want in the guest:

vagrant ssh
cd /vagrant
composer test

Is there a way of running composer test from the host machine inside the guest in a single step?

I could add the 3 steps to a vagrant provisioning script so they get run automatically on vagrant up. But, I want to be able to run composer test multiple times from the host during a single vagrant session and ideally without having to ssh into it first.

Upvotes: 0

Views: 300

Answers (1)

lee-pai-long
lee-pai-long

Reputation: 2282

Like ssh, vagrant ssh has a -c flag to run command directly, so you can do:

vagrant ssh -c "cd /vagrant && composer test" 

Upvotes: 1

Related Questions