Created
April 28, 2016 12:37
-
-
Save tentacode/c443c9d571484431756cd7899c811617 to your computer and use it in GitHub Desktop.
Script to execute a command directly in vagrant via `vg bin/somecommand --arg="some argument"`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
$cmd = ''; | |
for ($i = 1; $i < sizeof($argv); $i++) { | |
$arg = $argv[$i]; | |
if (preg_match('/^(--[^\- =]+=)(.+)$/', $arg, $matches)) { | |
$arg = sprintf('%s\"%s\"', $matches[1], $matches[2]); | |
} | |
$cmd .= ' '.$arg; | |
} | |
$cmd = sprintf('vagrant ssh -c "cd /vagrant && %s"', trim($cmd)); | |
system($cmd); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment