Problem run script inside a gnome-terminal

hi,

I would like to ask about using gnome-terminal command, I had a script that will run my VBOX VM in headless and i want to display the output(STDOUT) on the gnome-terminal window. The purpose that i want to display the STDOUT of the script cause i will used it or create a desktop shortcut for one click start all and want a visual display of the script running all the VM's for confirmation. The script works fine when i used in terminal. It failed to run the Script if i will used the "gnome-terminal -e" command. "Its like it runs all the command inside the script and STDOUT it on gnome-terminal window that pop-up and as soon as the script exit all the command inside the script will abort or simple the VM state will abort or stop running"already try all the option on gnome-terminal but unsuccesfull. Here are some i tried:

gnome-termial -e "bash /home/<location_script>/startvm.bsh" 
gnome-termial -e "/home/<location_script>/startvm.bsh

i also used --working-directory, profile i guess all argument in gnome-terminal.

My goal would be run all the command inside the script and if the script exit and also the gnome-terminal exit all the command inside the script won't be affected.

Hope someone knows something..

Thanks in advance..

So you want the command to run, and then once the command finishes, drop to a shell?

That works when you type it because it doesn't hit EOF once startvm.bsh finishes -- there's already another shell running, waiting for the keyboard. But when you run it as a command, your program is the only thing running. It hits a very literal 'end of file', decides its time to quit, and when it does there's absolutely nothing left running at all -- causing the terminal to quit.

If you want it to run another shell after, tell it to run another shell after. :slight_smile:

How about this?

gnome-terminal -x /bin/bash -c "/home/<location_script>/startvm.bsh ; exec /bin/bash"

A miniature shell-script on the commandline itself, telling it to run startvm.bsh first, then start a plain shell afterwards.

Thanks @corona688: I mean run gnome-terminal command which pop-up a gnome-terminal window. run & display the STDOUT of the startvm.bsh on the pop-up gnome-terminal for the purpose of displaying if command "vboxheadless ..." succesfully executed the VM then exit the script and then close the gnome-terminal window. Close all window(gnome-terminal) or shell etc. after displaying the STDOUT of the script but not affecting the command the script execute.

I already tried the command you give and succesfully powerof the vm and gnome-terminal won't close since another bash shell holding it. But as soon as the gnome-terminal close the same as the VM.(Its like sending a close signal to the command they executed before). I already tried putting "&" to background command but still no success.

It's not sending a 'close command', just informing it that whatever ran it is finished. It takes that to mean it has nothing left to do, and quits.

Naturally, since it would believe it's done immediately...

A shell script that waits forever once gnome-terminal quits:

/bin/bash -c "gnome-terminal -x /home/<location_script>/startvm.bsh ; while true ; do sleep 1000 ; done"

I tried to create a shorcut and put this command and works.

But i want to display the output of the /home/<location_script>/startvm.bsh

Is there any possible way to work this around. I like the terminal display window style.

Did you try the solution I gave you last post? If it didn't work, in what way did it not work?

@Corona688: I tried the command

But still the same problem. The gnome-terminal closes along with it the startvm.bsh.

Addition Info: Im comfused right now since the command above will loop forever in the terminal where i execute the command. therefore the VM must still power-on but why its poweroff after the gnome-terminal or maybe the script exit.I short even "/bin/bash -c *******" terminal up and running or put it to background "/bin/bash -c ******* & " still vm poweroff. As if the gnome-terminal or maybe the script dies it dies also the command inside the script "vboxheadless".

Is this perhaps the only window X11 has running? Like, running completely raw? No toolbars or such?

@Corona688: Please clarify what you mean in the above qoute?

Literally the only window. Nothing else. Not even desktop widgets and such.

AH ok..Nup im running it on a desktop system GDM DM.

I understand also right now if in the startvm.bsh script i execute the command inside the script "vboxheadless" in the child process. It throws also an error complaining gnome-terminal can't create child processes..

thanks for responce..

echo -n �Press any key to continue��
CFG=`stty -g`
stty -echo -icanon
dd count=1 1>/dev/null 2>&1
stty $CFG
echo