Forum
Noob question, get a script running at boot - Printable Version

+- Forum (http://forum.xbian.org)
+-- Forum: Software (/forum-6.html)
+--- Forum: Configuration (/forum-17.html)
+--- Thread: Noob question, get a script running at boot (/thread-2345.html)

Pages: 1 2


RE: Noob question, get a script running at boot - huibert - 14th Jun, 2014 06:31 AM

I don't know how else to phase it. I want to do something and i need help. That's all I'm saying.


Re: RE: Noob question, get a script running at boot - Smultie - 14th Jun, 2014 06:44 AM

(14th Jun, 2014 06:13 AM)IriDium Wrote:  I don't know where you are from or what your inclinations are, but "I want" does NOT bear well with in a free forum.

I, for one, will not assist in this thread any more.

That's a bit harsh. 'I want' is also just an alternative for 'I would like'.


RE: Noob question, get a script running at boot - CurlyMo - 14th Jun, 2014 06:56 AM

Feature request, grammar exam at registration Wink


RE: Noob question, get a script running at boot - josch - 14th Jun, 2014 07:43 AM

I don't think that it's a grammar thing what IrDium meant. I think it's because huibert is repeating what he wants,
even after he already got all he needs to know. He posted the full tutorial for Raspbian and just wanted to know
how to do it with XBian and he was already told that he can do the same things in Xbian like in Raspbian.

Now he should try the tutorial (his link) and ask again if something specific isn't working. But just repeating again
what he wants to do is like "Ok, now give it to me step by step - what key to press at first?" Tongue

The exactly howto - for compiling and running the script - is actually in the script he wants to run it self:
Quote:To Compile:
gcc -Wall -o fancontrol-hv2 Fancontrol-hv2.c -lwiringPi -lpthread

To Run automaticly at startup write the follwing before "exit 0" in /etc/rc.local:
/location/of/fancontrol-hv2 &
Source: http://www.raspberrypi.org/forums/viewtopic.php?t=30347&p=430009

So just try it and ask again if there occur any problems.


RE: Noob question, get a script running at boot - huibert - 14th Jun, 2014 08:22 AM

Well the problem for me is that I don't know how to get into an environment that resembles raspian. I know how to run code, I just don't know how to do it in xbian. The step by step guide doesn't show this.


RE: Noob question, get a script running at boot - josch - 14th Jun, 2014 04:29 PM

Ok, so it's a very very basic question. Sorry, it wasn't clear to me that you just don't know how to get to the
command line because you said you aren't new to unix. Nevermind - here you go:

As I already said, XBian is elementary based on Debian and so of course there is always a command line
running below. Wink To enter it, all you have to do is to exit XBMC. (XBMC Shutdown Button -> Quit)

You can do it also more comfortable via SSH. Using SSH you can run the commands from your PC and
won't need any keyboard on the Pi at all. But I would recommend to stop XBMC also, as this will speed up
the compiling process. You can stop/start XBMC service via:

Terminal
sudo service xbmc <stop|start|restart>



RE: Noob question, get a script running at boot - josch - 19th Jun, 2014 03:32 AM

So... did it work for you?

It's kind of disappointing to spend some lifetime for helping others, if there's no thanks or any feedback at all. Confused


RE: Noob question, get a script running at boot - huibert - 19th Jun, 2014 07:42 AM

(19th Jun, 2014 03:32 AM)josch Wrote:  So... did it work for you?

It's kind of disappointing to spend some lifetime for helping others, if there's no thanks or any feedback at all. Confused

I'm sorry, i didn't get a notification for that response, so i haven't tries it yet. It wasn't my intention to ignore anyone.

I'll try it as soon as i'm on my pc.

I'm sorry for not specifying the lack of my knowledge at the start.

SSH is what I needed to know, thank you very much Smile. It still doesn't work though, the script runs when I start it manually but it doesn't start from crontab or /etc/rc.local . I enabled cron, I added the line in cron but it doesn't work. Can anyone advise me what might be the problem with these 2 automatic services not working?


RE: Noob question, get a script running at boot - josch - 19th Jun, 2014 11:15 PM

(19th Jun, 2014 07:42 AM)huibert Wrote:  I'm sorry, i didn't get a notification for that response, so i haven't tries it yet. It wasn't my intention to ignore anyone. [...]

No problem! I just thought that you had already success. In this case I would have expected a short reply.
But of course, I didn't want to be harsh or offended only because you didn't answered fast enough. Tongue

(19th Jun, 2014 07:42 AM)huibert Wrote:  can anyone advise me what might be the problem with these 2 automatic services not working?

Ok, so let's face the /etc/rc.local method. - What exactly did you put in and where?

There are three important things you have to consider:
  1. your command must be put before the line exit(0)
  2. to keep the command running in the background you have to end the command with a &
  3. commands in /etc/rc.local are executed as root


Example:
If I would want to run a script after boot as user xbian and keep the script running, I would add a line like:

Code:
su xbian -c "/path/script &"

right before the exit(0) line in /etc/rc.local.

If you want to run the script as root, the part in the quotes (/path/script &) is all you need!


RE: Noob question, get a script running at boot - huibert - 20th Jun, 2014 01:24 AM

(19th Jun, 2014 11:15 PM)josch Wrote:  
(19th Jun, 2014 07:42 AM)huibert Wrote:  I'm sorry, i didn't get a notification for that response, so i haven't tries it yet. It wasn't my intention to ignore anyone. [...]

No problem! I just thought that you had already success. In this case I would have expected a short reply.
But of course, I didn't want to be harsh or offended only because you didn't answered fast enough. Tongue

(19th Jun, 2014 07:42 AM)huibert Wrote:  can anyone advise me what might be the problem with these 2 automatic services not working?

Ok, so let's face the /etc/rc.local method. - What exactly did you put in and where?

There are three important things you have to consider:
  1. your command must be put before the line exit(0)
  2. to keep the command running in the background you have to end the command with a &
  3. commands in /etc/rc.local are executed as root


Example:
If I would want to run a script after boot as user xbian and keep the script running, I would add a line like:

Code:
su xbian -c "/path/script &"

right before the exit(0) line in /etc/rc.local.

If you want to run the script as root, the part in the quotes (/path/script &) is all you need!

There we go, insufficient understanding of the rc.local . added the & and correctly started the program as root. Thank you for all your help.


RE: Noob question, get a script running at boot - CurlyMo - 20th Jun, 2014 01:28 AM

Didn't find this in the wiki FAQ yet Wink


RE: Noob question, get a script running at boot - josch - 20th Jun, 2014 11:21 PM

(20th Jun, 2014 01:28 AM)CurlyMo Wrote:  Didn't find this in the wiki FAQ yet Wink

done Wink