Shell script (sh) execution from within rc.local failure

Posted on 2004-10-15
Last Modified: 2012-06-21

I have created a Linux-based, CD-based router operating system for my router machine.  I have done the same thing before for several internet connections, but this is the first time I have ever used a DSL-based PPPoE connection.  All of the other routers I've built have been for purely Ethernet-based configuration with routing for a block of IPs, a firewall, NAT, port forwarding, and a serial-based console(s).

This one is a little simpler, since it's for my home -- only one (dynamic) IP, a firewall, some NAT with port forwarding, but no routing or serial consoles.  But this is the first time I've had to get PPPoE working.

I have PPPoE working via Roaring Penguin PPPoE; the CD copies various config files to the RAMdisk at boot time, and when I log in I can run /usr/sbin/adsl-start and everything connects and works fine.

However, if I try to run /usr/sbin/adsl-start from rc.local, I get an endless loop of errors like:

expr: command not found, and
-gt: unary operator expected, etc.

I really need to run this at boot-time, and I also need to run it before I can run my firewall scripts, because obviously the firewall needs to use the ppp interface.

I have seen these errors before, but admittedly my job revolves more around the cursed world of Microsoft/.NET software development, and I have shied away from the realms of Linux systems administration for the past two years.  Is this a permissions problem?  The files are all CHMODed for executable; and of course the shell is too.  The config files are also all readable.

This is a 2.4.2x kernel, running on a heavily modified version of the "Sentry Firewall CD" (  But again, I don't think any of that is as important; the whole shebang works from a login shell but not from rc.local!

Should I try like /bin/bash /usr/sbin/adsl-start?  Even though adsl-start is configured to run with sh with !#/bin/sh?

As you can see I'm not even sure where to begin.  Any pointers would be appreciated.

Thanks for any help
Question by:v2000
  • 2
  • 2

Expert Comment

ID: 12326439
My Shorewall firewall starts up before adsl-start,

do you use webmin on that machine? (well it'd make matters easier)
Try running the command "service adsl start" instead

otherwise, create an executable script file file with the following contents:

___________________COPY STARTS ON NEXT LINE______________________
# adsl                     This script starts or stops an ADSL connection
# chkconfig: 2345 99 01
# description: Connects to ADSL provider # # LIC: GPL # # Copyright (C) 2000 Roaring Penguin Software Inc.  This software may # be distributed under the terms of the GNU General Public License, version # 2 or any later version.

# Source function library if it exists
test -r /etc/rc.d/init.d/functions && . /etc/rc.d/init.d/functions


# Paths to programs
case "$1" in
        gprintf "Bringing up ADSL link"

      if [ $? = 0 ] ; then
            touch /var/lock/subsys/adsl
        echo ""

        gprintf "Shutting down ADSL link"

      $STOP > /dev/null 2>&1
      if [ $? = 0 ] ; then
            rm -f /var/lock/subsys/adsl
        echo ""

      $0 stop
      $0 start


        gprintf "Usage: adsl {start|stop|restart|reload|status}\n"
        exit 1

exit 0

___________________COPY ENDS HERE______________________

now save this file somewhere:
and then do a
chmod 700 /path/to/script
now in rc.local you can start it with the command:
/path/to/script start

Hope this makes sense


Accepted Solution

de2Zotjes earned 200 total points
ID: 12326537
The 2 errors that you state are most likely caused by referring to variables that are not set ( the -gt case) and calling programs that are not in the path (expr: command not found)

You could start your search for the culprits by dumping you environment when the adsl-start starts. Make the first line: env > /tmp/adsl_start_env

You can compare this environment with the one you have when you have a prompt:

env > /tmp/prompt_env
cd /tmp
diff prompt_env adsl_start_env | less

See what differs between the 2 and think about what consequences that might have for your start-script.

i realize this is not a solution, but it is more of a recipe to get to a solution :-)

Author Comment

ID: 12327767
Excellent.  I apologize for my idiocy; I never realized "expr" was a command.  But your response led me to check, and indeed, it was residing outside of the PATH for rc.local.  So I extended the PATH and exported it before I ran adsl-start, and everything worked fine.


Expert Comment

ID: 12486677
Would you mind closing the question ?

Author Comment

ID: 12486688
Sorry, I'm a total moron.  I guess the medication is getting to me :-)

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now