VirtualBox

Ticket #11011: VBoxScreen

File VBoxScreen, 942 bytes (added by Valery Ushakov, 7 years ago)

Quick proof of concept script to start vbox with serial port connected to a new screen window

Line 
1#!/bin/sh
2v=/path/to/VirtualBox/bin
3VirtualBox="$v"/VirtualBox
4VBoxManage="$v"/VBoxManage
5
6arg="$1"
7if [ "$arg" != "--child" ]; then
8 vmname="$arg"
9 if [ -z "$vmname" ]; then
10 echo usage: $0 vmname [...] 1>&2
11 exit 1
12 fi
13
14 shflags=
15 if [ -n "$-" ]; then
16 shflags=-$-
17 fi
18
19 exec screen -ln -t "$vmname" /bin/sh $shflags "$0" --child "$@"
20else
21 shift # that "--child" away
22fi
23
24fail() {
25 echo -n 'Press <ENTER> to continue...'
26 read input
27 exit 1
28}
29
30vmname="$1"
31if [ -z "$vmname" ]; then
32 echo usage: $0 vmname [...] 1>&2
33 fail
34fi
35
36if [ ! -t 0 ]; then
37 echo not a tty 1>&2
38 fail
39fi
40
41tty=$(tty)
42if [ -z "$tty" ]; then
43 echo unable to determine the name of the terminal 1>&2
44 fail
45fi
46
47"$VBoxManage" modifyvm "$vmname" --uartmode1 "$tty" || fail
48echo VBoxManage modifyvm \""$vmname"\" --uartmode1 \""$tty"\"
49
50exec < /dev/null > /dev/null # but leave stderr open
51
52exec "$VirtualBox" --startvm "$@"

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy