On second thought, Alvaro. It appears that this does NOT work!

Look more closely at the trace you posted. Is "hello" being output, or
"echo hello"? In fact, whatever you specify for the command to vagrant ssh
--no-tty -c <command>, the command string is simply reported to stdout
without actually executing anything. This is a problem.

So I take back what I said about updating the documentation, as the
documentation is unfortunately accurate: config.vm.ssh.shell does NOT alter
the shell invoked by vagrant ssh. Stupid, but true.

I am working around this limitation by having packer install Git Bash, and
sending commands over cygwin into my Windows box. I also submitted a PR to
try to fix the hardcoded shell for Windows boxes, but my Ruby code seems to
be off at the moment.

On Wed, Feb 21, 2018 at 12:35 PM, Andrew Pennebaker <
andrew.penneba...@gmail.com> wrote:

> Alvaro, thanks for the update! I can confirm that vagrant ssh -c is able
> to execute Windows shell commands when Vagrantfile is configured with
> config.vm.ssh.shell = "powershell.exe".
>
> Can we update the documentation now that config.vm.ssh.shell actually does
> affect vagrant ssh?
>
> https://www.vagrantup.com/docs/vagrantfile/ssh_settings.html
>
> On Mon, Feb 19, 2018 at 9:11 AM, Alvaro Miranda Aguilera <
> kiki...@gmail.com> wrote:
>
>> hi
>>
>> $ vagrant ssh -c "echo hello"
>>
>> echo hello
>>
>>
>> Connection to 127.0.0.1 closed.
>>
>>
>> $ cat Vagrantfile
>>
>> Vagrant.configure("2") do |config|
>>
>>   config.vm.box = "mcandre/windows"
>>
>>   config.ssh.shell = "powershell.exe"
>>
>> end
>>
>>
>>
>> alvaro.
>>
>>
>>
>>
>> On Sat, Feb 17, 2018 at 8:27 PM, Andrew Pennebaker <
>> andrew.penneba...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I would like to setup a Windows Vagrant box as a build bot for managing
>>> cross-platform application builds. The idea is to leverage Vagrant to
>>> compile systems programming language apps for C, C++, Rust, and the like,
>>> against a Windows target, regardless of which operating system the
>>> developer is using as host.
>>>
>>> I've gotten pretty far with this, setting up a Windows Vagrant box that
>>> can do most of the critical Vagrant things, like running downstream user
>>> file and shell provisioning in their Vagrantfile's, and vagrant rsync
>>> source code into the guest. `vagrant ssh` successfully launches a Command
>>> Prompt session that runs commands entered in over an interactive tty.
>>>
>>> Packer source:
>>>
>>> https://github.com/mcandre/packer-templates/tree/8ec39984f58
>>> 34ce8b8ebacdfcd63de0438154cc0/windows
>>>
>>> It's awesome that `vagrant ssh` works for interactive typing, however I
>>> want to be able to send commands over `vagrant ssh -c <command>`, in order
>>> to automate the application build steps. When I do this with other boxes
>>> like Debian, MINIX, FreeBSD, and so on, then it works great as a CLI-driven
>>> workflow! Unfortunately, `vagrant ssh -c "echo hello"` does not appear to
>>> work out of the box (pun intended) for Windows guests. Instead of
>>> outputting "hello", this prints a bunch of blank lines and then hangs
>>> indefinitely. If I add a --no-tty flag, the output complains of a missing
>>> bash program.
>>>
>>> I can imagine a number of workarounds, like setting up bash.exe (either
>>> from bash on Ubuntu on Windows, or Git Bash, or cygwin, or whatever). Or
>>> using `vagrant powershell` instead of `vagrant ssh`. But that would defeat
>>> the purpose of a cross-compilation VM, as this would require the host to
>>> also be Windows.
>>>
>>> Does anyone know of a Vagrantfile or packer configuration to fix
>>> `vagrant ssh -c ...` for Windows guests? Or should I look into forking and
>>> patching Vagrant itself? It's silly that `vagrant ssh` launches a working
>>> Command Prompt session, but `vagrant ssh -c` fails (and defaults to bash!)
>>>
>>> --
>>> This mailing list is governed under the HashiCorp Community Guidelines -
>>> https://www.hashicorp.com/community-guidelines.html. Behavior in
>>> violation of those guidelines may result in your removal from this mailing
>>> list.
>>>
>>> GitHub Issues: https://github.com/mitchellh/vagrant/issues
>>> IRC: #vagrant on Freenode
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Vagrant" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to vagrant-up+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/vagrant-up/5ce0e1a8-b484-49c2-a2f4-f13db6dd276f%40googlegroups.com
>>> <https://groups.google.com/d/msgid/vagrant-up/5ce0e1a8-b484-49c2-a2f4-f13db6dd276f%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Alvaro
>>
>> --
>> This mailing list is governed under the HashiCorp Community Guidelines -
>> https://www.hashicorp.com/community-guidelines.html. Behavior in
>> violation of those guidelines may result in your removal from this mailing
>> list.
>>
>> GitHub Issues: https://github.com/mitchellh/vagrant/issues
>> IRC: #vagrant on Freenode
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Vagrant" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/vagrant-up/eAF9GONHcMU/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> vagrant-up+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/vagrant-up/CAHqq0eyAjEoswvzEAuHOh0dCBFd9NoVeOuZpZvc5e-
>> dkMk8SuQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/vagrant-up/CAHqq0eyAjEoswvzEAuHOh0dCBFd9NoVeOuZpZvc5e-dkMk8SuQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Cheers,
> Andrew
>



-- 
Cheers,
Andrew

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vagrant-up+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vagrant-up/CAHXt_SW2Ej9LkEDxsP7uViiE%2BDCNiMceKN-CmLRmmXXUc2ckfg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to