Find the answer to your Linux question:
Results 1 to 8 of 8
Hi everybody, I wrote a script file like this; so i want to run this script file every time when i switch on the system........... My question is , how ...
  1. #1
    Linux Newbie
    Join Date
    Oct 2006
    Posts
    107

    how to run the script file at start up time

    Hi everybody,

    I wrote a script file like this; so i want to run this script file every time when i switch on the system...........
    My question is , how to run the script file at run level-6 , every time the system starts....
    ----------------------------------------------------------------------------------------------------------------
    #!/bin/shdvanced Search


    echo 'Testing MAC ADDRESSES '

    if arping -c 3 172.20.80.2
    then
    rm -f text
    touch text
    arping -c 1 172.20.80.2 >> text
    mac=$(awk '/^Unicast/ { gsub(/\[|\]/,"",$5);print $5}' "text")
    ifconfig eth0 down
    ip link set eth0 addr $mac
    service network restart
    rm -f text
    echo ' INTERNET CONNECTION IS ESTABLISHED SUCCESSFULLY'
    exit 1
    else

    echo ' NOT established'
    ---------------------------------------------------------------------------------------------------------------------------

    Thanks in Advance

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    Make a symbolic link of your script in /etc/rc6.d.
    The name of the link must start with an uppercase S followed by an unique 2 digit sequence number.
    Check the names of the other scripts in the directory. The scripts are executing in order if these numbers.

    Regards

  3. #3
    Linux Newbie
    Join Date
    Oct 2006
    Posts
    107

    doubt on script

    Hello ,

    I tried as well as u said , but it is showing like

    "/etc/rc6.d" is not modifiable, when iam trying to enter the entry in the corresponding file.

    Pls help me.....

  4. #4
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    You must have root permission to make the link.
    Log in as root and type:

    ln -s /yourdir/yourscript_name /etc/rc6.d/S95yourscript_name

    Regards

  5. #5
    Linux Newbie
    Join Date
    Oct 2006
    Posts
    107

    script

    Hello sir,

    I did as u said only, but still it is not working,

    when iam checking with "chkconfig --list Scriptname" , it is showing error reading information.

    And also, it is notshowing the script name when i issue the comand "chkconfig --list"




    Regards
    mallik

  6. #6
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,344
    Runlevel 6 means you are rebooting the system, so no services will run. Since thats just a script, I would put the contents in /etc/rc.d/rc.local or /etc/init.d/boot.local depending on the distro.

  7. #7
    Linux Newbie
    Join Date
    Oct 2006
    Posts
    107

    script

    Hi,

    I entered my script in the run level 5 only,

    when i check with chkconfig --list script_name, it is not showing the staus of the script

  8. #8
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,344
    Ordinary scripts don't work with chkconfig thats why I suggested you put the contents of your script in /etc/rc.d/rc.local or /etc/init.d/boot.local. If you want your srcipt to work with chkconfig, then take a look at some of the scripts in /etc/init.d and adjust your script to their format.

Posting Permissions

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