Page 1 of 1
[Solved] How to create unique path for serial port log file
Posted: 15. Jan 2018, 20:30
by ReneF
Good day experts,
To capture the Solaris boot messages that go to the console, I have changed the multiboot line to partially read "-B console=ttya".
Then, I am capturing the COM1 output in a raw file:

- serialport.png (25.17 KiB) Viewed 2258 times
The file you specifiy in Path/Address gets zeroed out at every start of your VM.
I tried using the windows vars %DATE% and %TIME% to generate a unique filename each time I start my VM, to prevent wiping out the console output of previous sessions, but the windows vars are not being expanded by VBOX.
Is there a way to make VBOX generate a unique filename to capture the serial port output in ?
Thanks in advance for your help,
Kind regards,
René
Re: How to create unique path for serial port log file
Posted: 15. Jan 2018, 20:45
by socratis
I'm moving this to "Using VirtualBox" from the "Solaris Guests". There may be more people lurking in that section.
The only thing I can think of would be to start the VM using a batch file, which checks for the existence of the file in question and renames/zips it and then launches the VM.
Re: How to create unique path for serial port log file
Posted: 16. Jan 2018, 10:22
by andyp73
I think that %DATE% and %TIME% are expansions that are specific to the Windows command processor and therefore only really applicable to the Windows command prompt and batch files running within them.
If a Windows application needs access to environment variables then typically it will use the GetEnvironmentStrings() and SetEnvironmentVariable() functions. It is also possible to set a Windows application to use its own environment block overriding the one it inherits from its parent process.
The suggestion by socratis to manipulate the file manually before launching the vm seems a simple one to me.
-Andy.
Re: How to create unique path for serial port log file
Posted: 16. Jan 2018, 20:43
by ReneF
Ok, thanks for the replies. Apparently there are no Virtualbox built-in variables for use. I created the following bat file:
Code: Select all
REM Script to start VM "%1" with a genereated UART1 filename
REM - if VM name changes, script needs to be modified too
REM
set datetime=%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%%time:~6,2%
set file=d:\VMBOX_machines%1\Console\Console_COM1_%datetime%.txt
echo >%file%
"C:\Program Files\Oracle\VirtualBox\vboxmanage" modifyvm "%1" --uartmode1 file %file%
"C:\Program Files\Oracle\VirtualBox\vboxmanage" startvm "%1"
If called with the VM name, it works like a charme. All set.
Re: How to create unique path for serial port log file
Posted: 16. Jan 2018, 22:09
by socratis
Not bad, not bad at all!!!

It may be helpful to others in the future, thanks for posting it! Marking as [Solved].