How can I get the computer to boot up and run a program/game w/ bash script or C++?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How can I get the computer to boot up and run a program/game w/ bash script or C++?
I'm not sure if this goes under programming or Linux from scratch, so I will put it in both. My question: Is there a way to get the computer to boot up, and run a program such as a game (no log in), either with some sort of bash script, or in place of bash, programmed in C++? If there is, how would I accomplish this? The system would need to shut down as soon as the game quit. Plus if the power was to shut off abruptly, the computer would still be able to boot, with no i-node errors. I would not even need to have a good computer because it should (hopefully) be a very stripped down Linux (no GUI). This is for an arcade game I'm programming for fun in C++ and Allegro, and I want to build an upright arcade case to put it in. The game will be a top down flight simulation (I hope that won't stop you from helping ).
/etc/rc.d contains all the scripts, if you are on a slack system it is about 8 scripts, change the rc.3 script, add a reference tou your own script at the end, then when the game is done in your script have it run init 0 to shut down the computer (init 6 to reboot)
if it is a redhat clone system it has scripts in /etc/initd(or something) that are linked to directories /etc/rc.d/rc.x
for what you want I would set initrc to runlevel 1, put only needed scripts including your own into rc1 directory and have all the shudown stuff run in runlevel1 after your stuff. if this is to vague then you might not be ready to tackle this, do some reasurch on the startup files, I neather want to, nor am I capeable of stepping you through this completely. sorry.
Thank you for your responses. I'm not sure I am presently good enough in scripting, so I'll try what exodist said, and if it doesn't work I will read up some more. Thanks again.
that is a VERY VERY VERY good shell scripting guide, very easy to understand, I failed a programming class (they taught VB and Pseudocode combined into a crappy ass language thats why I failed) then I read that and started a sourceforge project and got very into the shell scripting (more skimmed than read :-/) after that I took intro to programming at another school where they taught java and those bash skills helped me to ACE the class, now I am in my 3'rd quarter of programming taking java C#, and C++ simeltaniously. The bash stuff is easy and a good starting point, so definately go for it, and don't wait for it to happen get there and DO IT. lol good luck
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.