View Single Post
Old 03-09-2012, 10:34 PM   #1
jonnan001
Newbie
 
jonnan001's Avatar

 
Join Date: Sep 2012
Location: ,
Posts: 6
Default Linux Dosbox Trick

I'm fairly pleased with myself for figuring this out, and since I can't find anywhere on the Internet it mentions this, I'm posting it for people.

There is a Linux feature (intended for running scripts in an interpreter) called hashbang or shebang. Basically, if you have a text script that uses '#' to denote comments, in linux you can mark the script executable and put "#! /path/to/script-interpreter" as the first line, and when linux runs it it will use that interpreter.

Since DOSBox .conf files use #comments, it works perfectly well with DOSbox.
Thus:
#!/usr/bin/dosbox -conf
(configuration)
(end-of-file)

Configuration/Caveats

Where is dosbox installed?
From the command-line, type "whereis dosbox".

Permissions:
File needs to be marked 'executable'.

end-of-line character:
*has* to be linefeed (e.g. Unix), *not* carriage-return/linefeed (e.g. MS-DOS/Windows);
It will fail silently if it has the latter, but this can be fixed with a unix utility called 'dos2unix'. usage: dos2unix ~/bin/*
(This caught me offguard when porting gog.com games in, and I felt really stupid when I figured out why the exact same configuration was fine in one file, but just opened DOSBox in another - <G>.)

File Naming:
They do not need the .conf extension, and if you intend to open them via double clicking, they can be named anything. However if you want to run them from the command line, they need to be in a location Linux see's in your $PATH (ideally ~/bin/), and you probably want to avoid a name containing spaces: typing moo2 will work, typing "Master of Orion 2" will work but you actually need the quotes, clicking on the file "Master of Orion 2" with no quotes will work fine though.

I probably shouldn't be as annoyingly pleased with myself over this that I am . . . but hey, it's really quite nice and easy and loads stuff better than my previous system of manually adding games to gnome menus.

Jonnan
__________________
When life hands you Lemons, make Lemonade.
When life hands you the Pits, make Nerve Gas!
jonnan001 is offline                         Send a private message to jonnan001
Reply With Quote