LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-21-2015, 04:37 PM   #16
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Arch, Debian
Posts: 859

Rep: Reputation: 245Reputation: 245Reputation: 245

Quote:
Originally Posted by win_the_day_go_ducks View Post
when running:

Code:
sudo sh /etc/rc.local
It does work correctly. Running it without sudo does not.
This confirms my hypothesis. I am assuming that you must
a) run the command as root
b) have networking

I would try the if-up.d approach...
 
Old 01-21-2015, 04:57 PM   #17
win_the_day_go_ducks
LQ Newbie
 
Registered: Sep 2014
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by joe_2000 View Post
This confirms my hypothesis. I am assuming that you must
a) run the command as root
b) have networking

I would try the if-up.d approach...
ok... I am a newbie. What do I have to do in order to get that to work? Do I have to create a .conf file in that directory that points to my python script?

Last edited by win_the_day_go_ducks; 01-21-2015 at 05:01 PM.
 
Old 01-21-2015, 05:22 PM   #18
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Arch, Debian
Posts: 859

Rep: Reputation: 245Reputation: 245Reputation: 245
Quote:
Originally Posted by win_the_day_go_ducks View Post
ok... I am a newbie. What do I have to do in order to get that to work? Do I have to create a .conf file in that directory that points to my python script?
On your system you should have a directory /etc/network/if-up.d/
Put your python script in there, make sure it is executable and that it has the path to the interpreter in the first line:
Code:
#!/usr/bin/python
It should automatically execute once the networking is up.
 
Old 01-21-2015, 06:25 PM   #19
win_the_day_go_ducks
LQ Newbie
 
Registered: Sep 2014
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by joe_2000 View Post
On your system you should have a directory /etc/network/if-up.d/
Put your python script in there, make sure it is executable and that it has the path to the interpreter in the first line:
Code:
#!/usr/bin/python
It should automatically execute once the networking is up.
Thank you. I will give this a try. However, there are a lot of other files that are in the folder (/usr/local/lib/PlexConnect/) that I believe are also dependent for the program to run, not to mention other python scripts. I would imagine it would be a bad idea to copy all of those over to the if-up.d folder. Is there anyway to make something like the old dos batch files that could point to the script?

Thank you again.
 
Old 01-22-2015, 12:30 PM   #20
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Arch, Debian
Posts: 859

Rep: Reputation: 245Reputation: 245Reputation: 245
Sure. What batch scripts were in dos are bash scripts in Linux. Except they are a lot more powerful. So you could write a bash script that says
Code:
#!/bin/bash
cd /usr/local/lib/PlexConnect/
./PlexConnect.py
Put it into if-up.d and make it executable.

(I explicitly changed to the directory just to be on the safe side in case it's relevant)
 
Old 01-22-2015, 03:01 PM   #21
win_the_day_go_ducks
LQ Newbie
 
Registered: Sep 2014
Posts: 25

Original Poster
Rep: Reputation: Disabled
it still needs sudo to run...

Quote:
Originally Posted by joe_2000 View Post
Sure. What batch scripts were in dos are bash scripts in Linux. Except they are a lot more powerful. So you could write a bash script that says
Code:
#!/bin/bash
cd /usr/local/lib/PlexConnect/
./PlexConnect.py
Put it into if-up.d and make it executable.

(I explicitly changed to the directory just to be on the safe side in case it's relevant)
Thank you again for your help. But for some reason I am running into the same issue. I think it has something to do with the actual permission

I created a script called plexstart.sh containing the following:

Code:
#!/bin/bash
cd /usr/local/lib/PlexConnect/
./PlexConnect.py
I made it an executable using the follwing command:

Code:
sudo chmod +x plexstart.sh
I copied the file into the /etc/network/if-up.d. When I reboot, nothing happens (to indicate that it has worked). If I navigate to /etc/network/if-up.d and try running:

Code:
sh plexstart.sh
It starts to run, then stops with the same error:
Code:
Failed to create socket on UDP port 53: [Errno 13] Permission denied
However if I run the same command with sudo everything works just fine. Any ideas on what I'm doing wrong?

Thank you.

Last edited by win_the_day_go_ducks; 01-22-2015 at 03:06 PM. Reason: syntax
 
Old 01-22-2015, 03:10 PM   #22
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Arch, Debian
Posts: 859

Rep: Reputation: 245Reputation: 245Reputation: 245
Running the command prepended by sudo means running it as root. So what you are describing is expected behavior. The system should actually run scripts in if-up.d as root so I don't think that's a permission problem.

Hmm, if you want to debug this I guess you'll need some debugging output.
Can you change the script to the following:

Code:
#!/bin/bash
cd /usr/local/lib/PlexConnect/
./PlexConnect.py  > /tmp/plexconnect.log
Then reboot. Then post the output of
Code:
cat /tmp/plexconnect.log
 
Old 01-22-2015, 03:19 PM   #23
win_the_day_go_ducks
LQ Newbie
 
Registered: Sep 2014
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:

Then reboot. Then post the output of
Code:
cat /tmp/plexconnect.log
hmmm:

Code:
cat: /tmp/plexconnect.log: No such file or directory
So it looks like it's not even executing. If I do run the script manually (sh plexstart.sh) the log file is created showing the same error message as before.

Last edited by win_the_day_go_ducks; 01-22-2015 at 03:19 PM. Reason: syntax
 
Old 01-22-2015, 03:24 PM   #24
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Arch, Debian
Posts: 859

Rep: Reputation: 245Reputation: 245Reputation: 245
Hmm, can you try renaming the script from plexstart.sh to plexstart?
I think it maybe doesn't like the .sh extension. Sorry for not thinking about this before.
 
Old 01-22-2015, 03:37 PM   #25
win_the_day_go_ducks
LQ Newbie
 
Registered: Sep 2014
Posts: 25

Original Poster
Rep: Reputation: Disabled
Smile Solved!

Quote:
Originally Posted by joe_2000 View Post
Hmm, can you try renaming the script from plexstart.sh to plexstart?
I think it maybe doesn't like the .sh extension. Sorry for not thinking about this before.
THAT DID IT!

You are the man (or woman)! Thank you so much for your help!

Just to recap for any folks out there who came to this thread. In order to get start the PlexConnect software automatically I created a bash script called plexstart:

Code:
#!/bin/bash
cd /usr/local/lib/PlexConnect/
./PlexConnect.py
I then had to make it executable:

Code:
sudo chmod +x plexstart
Finally it had to be copied over to /etc/network/if-up.d

Reboot and it runs like a charm.

Thank you joe_2000 for all your help and coding!
 
Old 01-22-2015, 03:39 PM   #26
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Arch, Debian
Posts: 859

Rep: Reputation: 245Reputation: 245Reputation: 245
Quote:
Originally Posted by win_the_day_go_ducks View Post
Thank you joe_2000 for all your help and coding!
You are welcome, glad that it works now.
 
  


Reply

Tags
autostart, python, reboot


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Automatically starting oracle 11g database on system startup mlnm Linux - Newbie 6 12-16-2012 07:24 PM
Starting MySQL automatically on Slackware 10 on system startup abtimoteo Slackware 2 09-24-2007 02:40 AM
starting service automatically on reboot msteiner Linux - Newbie 2 06-15-2007 12:13 PM
startup backup agent automatically when reboot ashley75 Linux - General 1 07-18-2005 04:39 PM
Starting a vncserver instance automatically at startup paul.nel Linux - General 6 01-08-2004 09:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:32 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration