[Solved] How to create unique path for serial port log file

This is for discussing general topics about how to use VirtualBox.
Post Reply
ReneF
Posts: 2
Joined: 15. Jan 2018, 20:23

[Solved] How to create unique path for serial port log file

Post 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
serialport.png (25.17 KiB) Viewed 2105 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é
Last edited by socratis on 16. Jan 2018, 22:09, edited 1 time in total.
Reason: Marked as [Solved].
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How to create unique path for serial port log file

Post 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.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
andyp73
Volunteer
Posts: 1631
Joined: 25. May 2010, 23:48
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Assorted Linux, Windows Server 2012, DOS, Windows 10, BIOS/UEFI emulation

Re: How to create unique path for serial port log file

Post 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.
My crystal ball is currently broken. If you want assistance you are going to have to give me all of the necessary information.
Please don't ask me to do your homework for you, I have more than enough of my own things to do.
ReneF
Posts: 2
Joined: 15. Jan 2018, 20:23

Re: How to create unique path for serial port log file

Post 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.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How to create unique path for serial port log file

Post by socratis »

Not bad, not bad at all!!! ;)
It may be helpful to others in the future, thanks for posting it! Marking as [Solved].
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Post Reply