Scripting VM Console (tty access to VM console)

dominix

Active Member
Jan 10, 2012
41
3
28
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.
 

dominix

Active Member
Jan 10, 2012
41
3
28
GMT -10
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:

Rares

Active Member
Feb 28, 2017
66
5
28
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?
 

dominix

Active Member
Jan 10, 2012
41
3
28
GMT -10
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...
 

fabian

Proxmox Staff Member
Staff member
Jan 7, 2016
7,924
1,526
164
you can use the guest agent for that, does not require network access, but needs to be pre-baked into your install routine/image
 

fabian

Proxmox Staff Member
Staff member
Jan 7, 2016
7,924
1,526
164
or configure a serial console and script access to that
 

dominix

Active Member
Jan 10, 2012
41
3
28
GMT -10
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.
 

fabian

Proxmox Staff Member
Staff member
Jan 7, 2016
7,924
1,526
164
the guest agent has an 'exec' command, which is available via 'qm guest exec <VMID>'
 

Rares

Active Member
Feb 28, 2017
66
5
28
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 your own in 60 seconds.

Buy now!