LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   starting a programme from boot script in Etch (https://www.linuxquestions.org/questions/debian-26/starting-a-programme-from-boot-script-in-etch-618554/)

knobby67 02-04-2008 06:32 AM

starting a programme from boot script in Etch
 
Hi all I'm trying to get a programme to run from startup script, my script runs fine ie will say hello world, but won't start the programme. To run the programme from my start up I type

cd /root/software
./game


However this won't work, can anyone advise me how to I can tell my startup to go to a directory and start a game? Thanks :)

Dutch Master 02-04-2008 06:50 AM

Your script needs to be executable, but also properly set up. Store it in your home-dir, that's fine. Then, once the script works, you'd have to make a sym-link from the /etc/rc2.d dir to the script. Post your script to see if it's ok.

knobby67 02-04-2008 07:41 AM

Thanks Dutch Master but I'm unsure about some of your points, I'm using Etch and running the script (start up) from etc/init.d, I've made it executable by the
chmod -x startup
and made it run from
update-rc.d startup defaults.
my script runs as it will do things like print hello world.


Do I need to make it run from a hight number eg s99? To stop any conflicts?
If so I'm not sure how to allocate it's number base? thanks

Dutch Master 02-04-2008 07:44 AM

Yes, you'll need a number in the sym-link, otherwise the kernel doesn't know when to execute the script in the boot-sequence.

knobby67 02-04-2008 08:13 AM

Thanks but no luck. I really don't now why it won't start the game :(

Dutch Master 02-04-2008 08:39 AM

You still didn't post the script, so I can't tell if that's OK....

knobby67 02-04-2008 09:05 AM

Sorry my script says

echo "script running"
startx
./../../root/gamedirs/game




I think it's something to do with my code running using x? So it's trying to start before x has initialized?


I tried starting x from inside the code rather than from a startup script, eg system("startx") but this just does the same start x windows but no game running

Dutch Master 02-04-2008 09:20 AM

Your script isn't a script yet:
Code:

#! /bin/bash
# startup script

startx
sh /root/gamedirs/game

exit 0

This is :) However, X should start automatically if you've installed a window manager like xdm/kdm/gdm so you could ommit that part. I have a feeling you're trying to solve part of a larger problem, but if you tell us the exact problem in full (e.i. what you want to achieve) we can help you better.

knobby67 02-04-2008 09:33 AM

Hi I'm using a min install of Etch with xorg core. I'm running it in an old arcade cabinet for arcade emulators. If you just install xorg on etch you need to manually start X. It's running great except I need to do a startx and ./game to run. I want to get rid of this step and the use of a keyboard .
I run min Etch as it boots very fast.

However my game/frontend uses GLX so x need to be running.

I'm sure it's because my frontend tries to run before x has started fully, and my tests seem to confirm this but I'm ussure how to solve this?
Thanks

Dutch Master 02-04-2008 07:42 PM

OK, I understand. Your next step is one of 2 options:
a) tell the script to wait a certain time before executing the next command. You'll need to specify the waiting time long enough to be sure that X has started properly. This is the easiest option, but requires an absolute 100% guarantee that the X server will start within that time. (hint: you'll need the sleep command)
b) tell the script to test a specific X-related file to exist and it's contents before starting the next command. For this you'll need a loop and determine the outcome of all possibilities that the loop can give you. This is the most difficult but safest way.

Learn about scripting here: http://tldp.org/LDP/abs/html/

knobby67 02-05-2008 03:38 AM

Thanks dutch master tried the sleep but it doesn't work. I know the problem now, as far as I can tell whenever you start up X it produces the display as the very last thing. When you use GLX you call a display pointer, pointing to the screen, however as the very last thing in the boot sequence is to produce the screen it gives a null pointer, so no gui stuff can ever be produced before the actually system has booted up. The only way to start it is to use gnome or kde startup stuff.
So looks like I'll have to install gnome-core.

Hope tha makes sense basically x produces the screen pointer last thing, so whereever you call your code your variable to the screens returns null and segmentation faults.


All times are GMT -5. The time now is 12:00 AM.