Last active
January 7, 2019 07:34
-
-
Save hex128/a56e1d219cea73f69f73d4e01977d5cd to your computer and use it in GitHub Desktop.
A script to send SysRq key sequence to a VirtualBox guest
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
#!/bin/sh | |
if [ "$#" -ne 2 ]; then | |
echo "usage: $0 <uuid|vmname> <key>" > /dev/stderr | |
exit 1 | |
fi | |
case "$(echo "$2" | tr '[:upper:]' '[:lower:]')" in | |
0 ) K1='0B';; | |
1 ) K1='02';; | |
2 ) K1='03';; | |
3 ) K1='04';; | |
4 ) K1='05';; | |
5 ) K1='06';; | |
6 ) K1='07';; | |
7 ) K1='08';; | |
8 ) K1='09';; | |
9 ) K1='0A';; | |
b ) K1='30';; | |
c ) K1='2F';; | |
d ) K1='20';; | |
e ) K1='12';; | |
f ) K1='21';; | |
g ) K1='22';; | |
h ) K1='23';; | |
i ) K1='17';; | |
j ) K1='24';; | |
k ) K1='25';; | |
l ) K1='26';; | |
m ) K1='32';; | |
n ) K1='31';; | |
o ) K1='18';; | |
p ) K1='19';; | |
q ) K1='10';; | |
r ) K1='13';; | |
s ) K1='1F';; | |
t ) K1='14';; | |
u ) K1='16';; | |
v ) K1='2F';; | |
w ) K1='11';; | |
x ) K1='2D';; | |
y ) K1='15';; | |
z ) K1='2C';; | |
space ) K1='39';; | |
* ) | |
echo "unknown key: $2" > /dev/stderr | |
exit 1 | |
;; | |
esac | |
K2="$(echo "obase=16;ibase=16;${K1}+80" | bc)" | |
VBoxManage controlvm "$1" keyboardputscancode '1D' '38' '54' "$K1" "$K2" 'd4' 'b8' '9d' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://www.halfdog.net/Misc/TipsAndTricks/VirtualBox.html#MagicSysrq
https://en.wikipedia.org/wiki/Magic_SysRq_key