auto run script
Hi,
I have one problem interms of auto run script. I had one application that sets the mixer settings (incase of oss driver). I want to run this application executable whenever i switch ON my machine. So can u tell me what should i do?? where should i kept this exe and what is procedure ?? -Prashant |
add it to /etc/rc.local if you're on a system like redhat or fedora.
|
It can be different from a distro to an other, but in mine (Debian based) I just put the application shortcut in /home/...(username)/.kde/Autostart and it will be runed every time I log in.
|
Hi,
Thankx for ur reply.... I am using Montavista Linux pro 4.0. It dosen't have /etc/rc.local file. It has, dir structure ..... /etc | /rc.d | /init.d /rc0.d /rc1.d /rc2.d /rc3.d /rc4.d /rc5.d /rc6.d /rcS.d | | | | | | | | | | I am not able to understand where should i put exe? and one IMP point is that ...only putting exe in specific dir is ok ? or need to make any entry in somewhere in file/table/script ..otherwise how did os recognize that there is new exe that should be run by itself? -Prashant |
You should include more details in your post. For example: putting your distro in your profie; and in the post indicating the name of the application if it isn't one you wrote yourself; the type of application, gui or cli based; if it is a gui program, which window manager you are using, such as KDE or Gnome.
|
please post the content of this file: /etc/inittab
Yves. |
content of file: /etc/inittab
# /etc/inittab: init(8) configuration. # $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $ # The default runlevel. id:3:initdefault: # Boot-time system configuration/initialization script. # This is run first except when booting in emergency (-b) mode. si::sysinit:/etc/init.d/rcS # What to do in single-user mode. ~~:S:wait:/sbin/sulogin # /etc/init.d executes the S and K scripts upon change # of runlevel. # # Runlevel 0 is halt. # Runlevel 1 is single-user. # Runlevels 2-5 are multi-user. # Runlevel 6 is reboot. l0:0:wait:/etc/init.d/rc 0 l1:1:wait:/etc/init.d/rc 1 l2:2:wait:/etc/init.d/rc 2 l3:3:wait:/etc/init.d/rc 3 l4:4:wait:/etc/init.d/rc 4 l5:5:wait:/etc/init.d/rc 5 l6:6:wait:/etc/init.d/rc 6 # Normally not reached, but fallthrough in case of emergency. z6:6:respawn:/sbin/sulogin # What to do when CTRL-ALT-DEL is pressed. ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now # Action on special keypress (ALT-UpArrow). #kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work." # What to do when the power fails/returns. pf::powerwait:/etc/init.d/powerfail start pn::powerfailnow:/etc/init.d/powerfail now po::powerokwait:/etc/init.d/powerfail stop # This line provides a nice out-of-box experience. For regular use, you # should replace it with the proper getty lines below. con:2345:respawn:/sbin/getty console # /sbin/getty invocations for the runlevels. # # # The "id" field MUST be the same as the last # characters of the device (after "tty"). # # Format: # <id>:<runlevels>:<action>:<process> # # Uncomment these for a devfs system # #1:2345:respawn:/sbin/getty 38400 vc/1 #2:23:respawn:/sbin/getty 38400 vc/2 #3:23:respawn:/sbin/getty 38400 vc/3 #4:23:respawn:/sbin/getty 38400 vc/4 #5:23:respawn:/sbin/getty 38400 vc/5 #6:23:respawn:/sbin/getty 38400 vc/6 # # Uncomment these only for non-devfs systems # #1:2345:respawn:/sbin/getty 38400 tty1 #2:23:respawn:/sbin/getty 38400 tty2 #3:23:respawn:/sbin/getty 38400 tty3 #4:23:respawn:/sbin/getty 38400 tty4 #5:23:respawn:/sbin/getty 38400 tty5 #6:23:respawn:/sbin/getty 38400 tty6 # Example how to put a getty on a serial line (for a terminal) # # Uncomment these for a devfs system # #T0:23:respawn:/sbin/getty -L tts/0 9600 vt100 #T1:23:respawn:/sbin/getty -L tts/1 9600 vt100 # # Uncomment these only for non-devfs systems # #T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100 #T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100 # Example how to put a getty on a modem line. # # Uncomment this for a devfs system # #T3:23:respawn:/sbin/mgetty -x0 -s 57600 tts/3 # # Uncomment these only for non-devfs systems # #T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3 |
OK so the interesting script here is /etc/init.d/rc
Could you post the content of this one? Yves. |
/etc/init.d/rc file
----------------------- #! /bin/sh # # rc This file is responsible for starting/stopping # services when the runlevel changes. # # Optimization feature: # A startup script is _not_ run when the service was # running in the previous runlevel and it wasn't stopped # in the runlevel transition (most Debian services don't # have K?? links in rc{1,2,3,4,5} ) # # Author: Miquel van Smoorenburg <miquels@cistron.nl> # Bruce Perens <Bruce@Pixar.com> # # Version: @(#)rc 2.78 07-Nov-1999 miquels@cistron.nl # # Un-comment the following for debugging. # debug=echo # # Start script or program. # startup() { case "$1" in *.sh) $debug sh "$@" ;; *) $debug "$@" ;; esac } # Ignore CTRL-C only in this shell, so we can interrupt subprocesses. trap ":" INT QUIT TSTP # Set onlcr to avoid staircase effect. stty onlcr 0>&1 # Now find out what the current and what the previous runlevel are. runlevel=$RUNLEVEL # Get first argument. Set new runlevel to this argument. [ "$1" != "" ] && runlevel=$1 if [ "$runlevel" = "" ] then echo "Usage: $0 <runlevel>" >&2 exit 1 fi previous=$PREVLEVEL [ "$previous" = "" ] && previous=N export runlevel previous # Is there an rc directory for this new runlevel? if [ -d /etc/rc.d/rc$runlevel.d ] then # First, run the KILL scripts. if [ $previous != N ] then for i in /etc/rc.d/rc$runlevel.d/K[0-9][0-9]* do # Check if the script is there. [ ! -f $i ] && continue # Stop the service. startup $i stop done fi # Now run the START scripts for this runlevel. for i in /etc/rc.d/rc$runlevel.d/S* do [ ! -f $i ] && continue if [ $previous != N ] && [ $previous != S ] then # # Find start script in previous runlevel and # stop script in this runlevel. # suffix=${i#/etc/rc.d/rc$runlevel.d/S[0-9][0-9]} stop=/etc/rc.d/rc$runlevel.d/K[0-9][0-9]$suffix previous_start=/etc/rc.d/rc$previous.d/S[0-9][0-9]$suffix # # If there is a start script in the previous level # and _no_ stop script in this level, we don't # have to re-start the service. # [ -f $previous_start ] && [ ! -f $stop ] && continue fi case "$runlevel" in 0|6) startup $i stop ;; *) startup $i start ;; esac done fi # eof /etc/init.d/rc |
OK. As you see from the first file, you're in runlevel 3. As you see from this second file, you will thus more or less execute all /etc/rc.d/rc3.d/K* then S* scripts.
Could you run (as root): ls -l /etc/rc.d/rc3.d/ You'll probably find that one service there is named S##*local* (a S* link with "local" in the name), if that is so, post the content of this file (the link probably points to a file in /etc/rc.d/init.d). Yves. |
ls -l /etc/rc.d/rc3.d/
lrwxrwxrwx 1 root root 16 Mar 30 2006 S10syslog -> ../init.d/syslog lrwxrwxrwx 1 root root 20 Mar 30 2006 S19nfs-common -> ../init.d/nfs-common lrwxrwxrwx 1 root root 15 Mar 30 2006 S20inetd -> ../init.d/inetd lrwxrwxrwx 1 root root 19 Mar 30 2006 S88demo -> ../init.d/dvevmdemo lrwxrwxrwx 1 root root 15 Mar 30 2006 S90mvltd -> ../init.d/mvltd lrwxrwxrwx 1 root root 19 Mar 30 2006 S99rmnologin -> ../init.d/rmnologin so here, no any service named S##*local*. ?? |
Suppose i put my exe in "/etc/init.d/". will it work??
|
nope, won't do a thing. what distro are you using? if you want to add a local service you'd just create a link from S99local in your chosen runlevel directory as above, to /etc/rc.local and then ad whatever command to that script, after setting /etc/rc.local as an exectuable script.
|
I am using Montavista Linux Pro 4.0
There is no any /etc/rc.local file . I have mentioned already distro and the dir structure under /etc |
oh yeah, fair enough... so as above then... does that make sense?
|
All times are GMT -5. The time now is 05:24 AM. |