LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   auto execute shell script on startup (https://www.linuxquestions.org/questions/slackware-14/auto-execute-shell-script-on-startup-294891/)

slackwbas 02-25-2005 04:59 PM

auto execute shell script on startup
 
hi.i have a question about how to execute a shell script on start up..
the shell script is for my usb modem alcatel speedtouch. to establish the connection
and here its the shell script

echo "Starting Speed touch connection script [by Darkflow]"
echo "Getting ready to start USB modem and mounting USB device file systems..."
modprobe ppp_generic
modprobe ppp_synctty
modprobe n_hdlc
mount none /proc/bus/usb -t usbdevfs
echo "Done"
echo "Loading Speedtouch modem Firmware (will take around 30 seconds)..."
modem_run -f /etc/ppp/microcode.dat
echo "Connecting: ADSL with pppd..."
pppd call adsl updetach
echo "Done. You are now online."

and i tried to edit /etc/rc.d/rc.S and put /myshell.sh in the rc.S
to start on boot...but the problem is that the shell script starts but its didnt connect
and sayed conection terminated...but when i start this script after login to the sys its works
well...some one told me that i should use startproc command or startdaemon
so i should edit the rc.S and put
startproc -s /myshell.sh
and i have slackware 10.0 ..and there is no startproc in it
....any body have any idea ??
thanx

tank728 02-25-2005 05:05 PM

The file you need to edit is /etc/rc.d/rc.local
just add
Code:

/path/to/myshell.sh
and you should be ready to go. You might
consider using the `&` to run it in the
background, if it is going to take a long time.

-tank

kostian 02-25-2005 05:10 PM

try /etc/rc.d/rc.local
when rc.S is executed the system is in singeluser mode and network services arent initialized yet.

EDIT: sorry slow typer :)

ralvez 02-25-2005 05:16 PM

OK I think I understand.
start a konsole session, then look for a hidden file called .bash_profile. If you do not find it in your home directory then it does not exit. Create it with pico (use pico .bash_profile).
If the file exist, edit it with a link to your script.
The next time you log into your system that file will run.

HOpe this helps.

Rick

slackwbas 02-25-2005 05:17 PM

i tried to put /myshell.sh in rc.local too but the shell script is executed and didn't connect ..and its wont me to enter the system cause its takes alot of time to connect and didn't connect...its just trying many many channels to connect but its didn't work,,,
and what you mean by '&' to make the script run in the background ??
you mean add
& /path/to/myshell.sh
??
any idea?

slackwbas 02-25-2005 05:43 PM

yes its worked ralvez..thanx alot....the script starts as will as i logged in..
but is that mean that i cant start the connection before i log in??
and is there any way else to made this script starts ..as will as any one logged in without editing bash-profile for every user
???
thanx

ralvez 02-25-2005 07:28 PM

.bash_profile is a file that is "personal" to each individual user.
In your particular case you want to activate you Internet connection, wight? Well, then what would be the point to start the connection *before* you are connected?
My apologies if I do not interpret your question correctly but given what you are trying to do seems to me the logical choice.

Rick

killerbob 02-25-2005 08:32 PM

He might be running servers....

In any case, since it's an internet connection script to do with actually connecting, I'd tack it on to the end of /etc/rc.d/rc.inet1 instead of rc.local. Either copy the script as it stands into rc.inet1, or reference it by calling /path/to/myscript.sh, and make certain that myscript.sh has executable permissions. I'd suggest chmod 755 for that. And you can solve any timeout issues by using the "sleep" command. Throw a "sleep 2" in after each modprobe and a "sleep 30" after the firmware call, and it'll probably fix the script for use at startup.

slackwbas 02-27-2005 05:35 AM

hi..i tried put the script in the end of rc.inet1 and rc.inet2 but it wont work i think the network service didnt intialized yet..so is that mean that i cant start the connection before the login??
thanx

gbonvehi 02-27-2005 10:26 AM

Try putting this on /etc/rc.d/rc.local:
Code:

echo "Starting Speed touch connection script [by Darkflow]"
echo "Getting ready to start USB modem and mounting USB device file systems..."
modprobe ppp_generic
modprobe ppp_synctty
modprobe n_hdlc
mount none /proc/bus/usb -t usbdevfs
echo "Done"
echo "Loading Speedtouch modem Firmware (will take around 30 seconds)..."
modem_run -f /etc/ppp/microcode.dat
echo "Connecting: ADSL with pppd..."
pppd call adsl updetach &
echo "Done. You are now online."

Note the & at the end of pppd, that will make it go background (you need this because pppd will stay running until you disconnect, this is why it "hung" when you booted) and if all goes ok your system will start.
You can get the same effect if you already have a script, and you call it from rc.local with a & at the end of the line.


All times are GMT -5. The time now is 01:41 PM.