LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 08-04-2010, 11:36 AM   #1
bolter40k
LQ Newbie
 
Registered: Jul 2010
Posts: 11

Rep: Reputation: 0
need help running a shell program on startup as root in a terminal


Hi,

I am running Linux Mint 9

I play xbox live and run it through my laptops wireless network connection so i dont have to pay 100 dollars for the usb wireless adapter for the xbox. In windows 7 this is easy to configure so that when i turn my laptop on and then xbox it automatically connects. I wrote a program that enables ip forwarding it is written as follows
Code:
#!/bin/bash -e
ifconfig eth0 up
ifconfig eth0 192.168.2.0
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o wlan0 -s 192.168.2.0/24 -j MASQUERADE
but when i run it as root nothing happens and my xbox wont connect to live. But when i manually type in these commands after su to root it works

also my startup file is rc.local as ive read an in it ive written the path to my program so it will be run how can i tell it is being run and how do i tell it to run as root?
Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/home/dylan/xboxlive.sh
thanks, bolter40k
 
Old 08-04-2010, 11:53 AM   #2
qweasd
Member
 
Registered: May 2010
Posts: 439

Rep: Reputation: Disabled
May be it's because bash -e exits right after a command returns a non-zero value.
 
Old 08-04-2010, 12:33 PM   #3
bolter40k
LQ Newbie
 
Registered: Jul 2010
Posts: 11

Original Poster
Rep: Reputation: 0
changed it it still wont work
 
Old 08-04-2010, 12:52 PM   #4
qweasd
Member
 
Registered: May 2010
Posts: 439

Rep: Reputation: Disabled
Quote:
also my startup file is rc.local as ive read an in it ive written the path to my program so it will be run how can i tell it is being run and how do i tell it to run as root?
It will run as root. If you are really suspecting that rc.local is not being run, try echoing something from there, like echo hello > /tmp/hello .

Does your script work if you run it from a terminal, as root, after the computer is fully booted? If so, then may be your desktop environment (which, I guess, starts up after rc.local) is messing up your card settings.
 
Old 08-04-2010, 01:19 PM   #5
bolter40k
LQ Newbie
 
Registered: Jul 2010
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by qweasd View Post
It will run as root. If you are really suspecting that rc.local is not being run, try echoing something from there, like echo hello > /tmp/hello .

Does your script work if you run it from a terminal, as root, after the computer is fully booted? If so, then may be your desktop environment (which, I guess, starts up after rc.local) is messing up your card settings.
well for some reason my script doesnt work when run by itself (right click>open as admin) doesnt seem to work at all
I cant seem to figure out where i went wrong especially considering when i enter these commands in myself it always works
 
Old 08-04-2010, 01:37 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,894

Rep: Reputation: 746Reputation: 746Reputation: 746Reputation: 746Reputation: 746Reputation: 746Reputation: 746
What are the permissions of your script?
 
Old 08-04-2010, 01:43 PM   #7
bolter40k
LQ Newbie
 
Registered: Jul 2010
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
What are the permissions of your script?
this is only way i know of gettin permissions in a terminal i hope its what your looking for

Code:
dylan@dylan-laptop ~ $ ls -l
total 40
drwxr-xr-x   2 dylan dylan 4096 2010-07-31 14:45 Desktop
drwxr-xr-x   8 dylan dylan 4096 2010-07-31 19:05 Documents
drwxr-xr-x   7 dylan dylan 4096 2010-08-04 13:53 Downloads
drwxr-xr-x   5 dylan dylan 4096 2010-07-31 22:15 Ebook
drwxr-xr-x 133 dylan dylan 4096 2010-07-31 23:10 Music
drwxr-xr-x   6 dylan dylan 4096 2010-08-03 04:19 Pictures
drwxr-xr-x   2 dylan dylan 4096 2010-07-31 14:45 Public
drwxr-xr-x   2 dylan dylan 4096 2010-07-31 14:45 Templates
drwxr-xr-x   5 dylan dylan 4096 2010-08-01 01:53 Videos
-rwxr-xr-x   1 dylan dylan  173 2010-08-01 21:36 xboxlive.sh
 
Old 08-04-2010, 02:48 PM   #8
qweasd
Member
 
Registered: May 2010
Posts: 439

Rep: Reputation: Disabled
What if you run it like this:

Code:
cd
su
./xboxlive.sh
 
Old 08-04-2010, 03:47 PM   #9
bolter40k
LQ Newbie
 
Registered: Jul 2010
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by qweasd View Post
What if you run it like this:

Code:
cd
su
./xboxlive.sh
yes that worked thanks... so it has to be executed as root but why doesnt it run at start up
 
Old 08-04-2010, 05:25 PM   #10
bolter40k
LQ Newbie
 
Registered: Jul 2010
Posts: 11

Original Poster
Rep: Reputation: 0
bump
 
Old 08-04-2010, 07:39 PM   #11
qweasd
Member
 
Registered: May 2010
Posts: 439

Rep: Reputation: Disabled
May be your DE is messing with the card? What does /sbin/ifconfig output look like after you boot?
 
  


Reply

Tags
forwarding, ip, rclocal, root


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
is there a way to tell if a C program is running without a terminal? MrUmunhum Linux - General 4 05-11-2010 01:21 PM
running a shell script which invokes another shell program!!! raghu123 Programming 1 08-04-2008 09:10 AM
Running program from terminal with & does nothing, program stops DittoAlex Linux - General 1 10-05-2007 01:35 AM
running program at startup noir911 Linux - General 2 01-08-2007 08:46 PM
Running a program at startup allomeen Linux - General 5 02-15-2006 06:36 PM


All times are GMT -5. The time now is 04:56 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration