I was following an instruction to deploy an application on a virtualbox VM and I was supposed to execute some long commands. at first it’s not possible to copy those command into the VM. virtualbox has a shared clipboard feature which I tried it first and it didn’t work so I didn’t dig in to debug it and I came up with a hack :D

I sent the commands through a socket :)

I opened a socket on my host using the following command (ncor netcatis builtin in linux distros)

$ nc -l 4567

now the it listens on 4567

and I connected to the socket from the VM via

$ nc 4567 | tee cmds.sh

the first part (before pipe) opens a socket to the remote address and the second part (after pipe) writes the received texts to a file named cmds.sh .

and then obviously I ran the commands I wanted via

$ sh -C cmds.sh

Have fun :)



Mehdi Khoshnoodi

Passionate about software architecture, leadership and startups ~ Tech Lead