Scripting VM Console (tty access to VM console)

dominix

Well-Known Member
Jan 10, 2012
41
3
48
GMT -10
Hi everyone,

Excuse me if this question has already been posted, but I could not find any solution.

My question is about to script the console of a VM.

I want to start a pre-configured VM with an automatic builded config, and launch some command inside the VM (when the prompt is ready), so it load some datas, programs, stuff and so on.

starting the pre-conf VM is easy but How do I launch command on the console of the VM from the command line of the proxmox server and Wait for the end of the command(s) ? (with optional return value)

I do not need no GUI nor web interface, I am used to "expect" and tools like that.

thanks for your help, dear proxmox'sers.

Cheer from Tahiti.
 
Hi r.jochum

Not exactly. I need a TTY access to the console of the VM so I can launch some init/install/populate script directly on the console. The VM is not necessarily linked to the administration LAN. In some case there could be no IP link between proxmox shell and the hosted VM, and the VM may have no ssh already installed.
 
Last edited:
You want something similar with the console that pops up when you do Proxmox packets update from the web but to run on your machine?

What about modifying /etc/inittab to display your software instead of the login prompt on a specific tty?
 
I am looking for something in command line not web or vnc interface.
If I could go throught some proxy like qm vncproxy that could allow me to send a command line to the shell, it will be fine.
It is possible to do that with virtualbox, so I thought it would be possible with proxmox...
 
you can use the guest agent for that, does not require network access, but needs to be pre-baked into your install routine/image
 
or configure a serial console and script access to that
 
it seem doable with
Code:
serial0: socket
in the VM definition, and a VM that has a tty that listen to ttyS0@115200.
so one can just
Code:
qm terminal VMID
to access to the running VM.
 
the guest agent has an 'exec' command, which is available via 'qm guest exec <VMID>'
 
I want to thank you all for all the responses because I just realized that I need something similar for a project I'm running right now :)
 
  • Like
Reactions: dominix

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!