LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-02-2007, 04:26 AM   #1
Josephus Ross
LQ Newbie
 
Registered: Mar 2007
Posts: 22

Rep: Reputation: 15
Problems with getting a script running on boot


Hi there all,

I have a script I have written that I am trying to run on start up. I have put the command in rc.local file but when the computer loads up it trys to run the script over the 'login' entry instead of running it in the background. This causes an issue as my script uses hcitool amongst other bluez commands and it seems that it cannot access these until I have logged in.

To get the program to run correctly I have to enter my login details and then action the script again whereby it works perfectly.

my rc.local file looks like this;

#!/bin/sh
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.

mycommand &


I have tried running the command without the '&' but still it doesn't work.

Any help would be greatly appreciated.

Cheers

Joe
 
Old 03-02-2007, 08:02 AM   #2
Vincent_Vega
Member
 
Registered: Nov 2003
Location: South Jersey
Distribution: Slackware, Raspbian, Manjaro
Posts: 826

Rep: Reputation: 31
What about just making a separate (executable) rc.your_command file with the command. Maybe that would let it get executed and run in the background.
 
Old 03-05-2007, 05:08 AM   #3
Josephus Ross
LQ Newbie
 
Registered: Mar 2007
Posts: 22

Original Poster
Rep: Reputation: 15
Hi VV

Thanks for your suggestion. I tried this but it didn't seem to do anything. Do i need to do anything else to get rc.myscript to action at boot or do I just create the file?

Joe
 
Old 03-05-2007, 05:19 AM   #4
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Rep: Reputation: 32
Quote:
Originally Posted by Josephus Ross
To get the program to run correctly I have to enter my login details and then action the script again whereby it works perfectly.
I think this is a case of missing environmental variable(s). Try exporting the environmental variables in the script itself.
 
Old 03-05-2007, 05:34 AM   #5
Josephus Ross
LQ Newbie
 
Registered: Mar 2007
Posts: 22

Original Poster
Rep: Reputation: 15
I am now outputting the command to a log file so rc.local looks as follows

#!/bin/sh

#:/root:/bin/bash

#/etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.

mycommand > /mydirectory/log/output.log 2>&1


I can now see clearly what the error message is. It seems to relate specifically to the hcitool command in bluez. I get the following error;

hcitool: command not found

However when I log in it finds the hcitool command and executes perfectly
 
Old 03-05-2007, 05:38 AM   #6
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Rep: Reputation: 32
I think your PATH variable is the problem. No doubt it can find hcitool. Put this line in the top of your script:
export PATH="$PATH:_path_to_hcitool"
 
Old 03-05-2007, 11:18 AM   #7
Josephus Ross
LQ Newbie
 
Registered: Mar 2007
Posts: 22

Original Poster
Rep: Reputation: 15
This worked perfectly thanks man!!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problems with running script Nurzat Programming 6 03-10-2009 04:11 AM
Running a script on boot Brynn Linux - Software 3 08-04-2006 08:09 AM
running script at boot time bigtl Fedora 3 12-19-2005 11:30 AM
Running a script to start WiFi on boot nanodano Linux - Hardware 3 11-06-2005 09:00 PM
problems running php script rhuser Linux - Software 5 02-14-2003 01:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration