<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ruslan&#39;s Tech Blog</title>
    <link>https://blog.bekenev.net/tags/virtualbox-terminal.html</link>
    <description>Software development related stuff</description>
    <language>en-us</language>
    <lastBuildDate>Sun, 18 Feb 2018 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://blog.bekenev.net/tags/virtualbox-terminal/feed.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>VirtualBox get IP of VM (cli)</title>
      <link>https://blog.bekenev.net/2018/02/18/run-commands-on-guest-vm.html</link>
      <pubDate>Sun, 18 Feb 2018 00:00:00 +0000</pubDate>
      <guid>https://blog.bekenev.net/2018/02/18/run-commands-on-guest-vm.html</guid>
      <description>&lt;p&gt;Here is command to run from CLI to get &lt;code&gt;ifconfig&lt;/code&gt; output on guest machine (with ubuntu server):&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;vboxmanage guestcontrol &amp;lt;vm name&amp;gt; run --exe &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;/sbin/ifconfig&amp;#39;&lt;/span&gt; --username &amp;lt;username&amp;gt; --password &amp;lt;pass&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br/&gt;&#xA;**Make sure GAs are installed on the guest**&#xA;&lt;p&gt;You can write shell function to simplify the call:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; vbox-get-ip&lt;span style=&#34;color:#f92672&#34;&gt;()&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt; -z $1 &lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;; &lt;span style=&#34;color:#66d9ef&#34;&gt;then&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       echo &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;pass VM name&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;fi&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    vboxmanage guestcontrol $1 run --exe &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;/sbin/ifconfig&amp;#39;&lt;/span&gt; --username &amp;lt;username&amp;gt; --password &amp;lt;pass&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br/&gt;&#xA;Now just call `vbox-get-ip &lt;vm name&gt;` and `ifconfig` output will be shown!&#xA;&lt;br/&gt;&#xA;&lt;p&gt;Sure you can execute other commands on the host. Just make sure you pass full path to the binary.&lt;/p&gt;&#xA;</description>
    </item>
  </channel>
</rss>
