Find the answer to your Linux question:
Results 1 to 2 of 2
Originally Posted by Flatline I had to do some digging through my "storage" drive, but here's a script I used to use (I haven't had a Debian install in a ...
  1. #1
    Just Joined!
    Join Date
    Dec 2008
    Posts
    1

    what, where, how?

    Quote Originally Posted by Flatline View Post
    I had to do some digging through my "storage" drive, but here's a script I used to use (I haven't had a Debian install in a while...don't hold it against me, please) to list active services:

    Code:
    #!/bin/sh
    
    # List files run at boot time in each run level
    
    list_level() {
        level=$1
        echo Level: $level
        for f in /etc/rc${level}.d/*; do
    	# Remove /etc/Knn or Snn from beginning
    	ff=$(echo $f | sed 's_/etc/rc..d/[KS][0-9][0-9]__')
    	if [ $f != $ff ]; then
    	    echo $ff
    	fi
        done
        echo ""
    }
    
    list_all() {
        for l in 0 1 2 3 4 5 6 S; do
            list_level $l
        done
    }
    
    if [ $# -eq 0 ]; then
        # Try to guess the default runlevel from /etc/inittab
        l=$( grep initdefault /etc/inittab | egrep -v '^ *#' | cut -d : -f 2 )
        if [ $l == "" ]; then
            list_all
        else
            list_level $l
        fi
    elif [ $1 == "-a" ]; then
        list_all
    else
        for l in $*; do
    	list_level $l
        done
    fi
    Looks fun.. what do I do with it?
    Where do I put it? How do I run it?
    How do I get *it* to auto run every time????
    ta

  2. #2
    Linux Newbie sdimhoff's Avatar
    Join Date
    Jan 2007
    Posts
    191
    Lets assume the script has a filename of "scriptname"

    To make a script executable:

    chmod +x /path/to/scriptname

    This will enable the executable flag. Now all you have to do to run it is:

    1.) While in the same directory as the script
    ./scriptname

    2.) In a different directory than the script
    /path/to/scriptname

    For the automatically running part, when do you want it to run? You can have the script run say at the start of a given runlevel.

    For instance, if you wanted it to start with x then put the path in your /home/.xinitrc file

    Hope that helps
    Linux since: 2001
    Gentoo since: 2004
    - - - - - - - -
    Translation:
    I fix things until they break.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...