I have a raspberry pi and run dosbox from the command line. Is it possible to write a script to run dosbox and shutdown Linux "sudo halt" after i have exited dosbox.

something like

#run dosbox 
#after exiting dosbox shutdown Linux
sudo halt
exit 0 

1 Answer 1


The code

echo "sudo shutdown -h now" | /usr/bin/at now + 10 min >/dev/null 2>&1
exit 0

will give the instruction to shut down the Pi (inserting a suitable delay) and exit the script cleanly. Here we have redirected the output to make it 'silent'.

  • sudo shutdown -h +10 wold have the same effect without calling at. I'm pretty sure that the OP wanted the Raspberry Pi to shutdown cleanly as soon as dosbox had finished, though.
    – scruss
    Commented Jan 19, 2014 at 16:41
  • I want the script detect when dosbox has closed then halt linux Commented Jan 19, 2014 at 20:00
  • I think your original script will? It just wouldn't exit your script cleanly, whereas a small delay would.
    – mirams
    Commented Jan 24, 2014 at 21:55
  • If there's nothing else for the script to do, there's no need to exit it "cleanly".
    – TomG
    Commented Apr 19, 2014 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.