Bash help: open terminal, execute command, shutdown

I'm trying to make a bash script that opens a terminal, executes a command and then shuts down my computer when everything is finished.
I got everything working except the shutdown.

This works:

#!/bin/bash
gnome-terminal -- bash -c "arguments='f'; bash '/home/hanne/myRender.sh' $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS $arguments"

(The reason I put 'f' in a variable is because I get an error when I use 'f' instead of $arguments)

This also works when types in the terminal:

shutdown -P +3

But when I try to combine them, it seems to ignore the shutdown part (It closes the terminal window without error but also without shutting down):

#!/bin/bash
gnome-terminal -- bash -c "arguments='f'; bash '/home/hanne/Documents/Design/Workflow - 3D/Scripts blender/myRender.sh' $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS $arguments; shutdown -P +3"

Anyone have tips for how I would achieve this?

Have you attempted making another call to bash for the shutdown command? Possible changing the semicolon before shutdown to dual ampersands(; -> &&)?

1 Like

I already tried replacing the ';' with '&&' but that didn't work.
But using multiple 'gnome-terminal' commands does work! Thanks!

gnome-terminal -- bash -c "arguments='f' && bash '/home/hanne/Documents/Design/Workflow - 3D/Scripts blender/myRender.sh' $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS $arguments"
gnome-terminal -- bash -c "shutdown -P +3"

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.