Menu

Main Menu
Talk Get Daily Search

Member's Online

    User Name
    Password

    [Linux bash] Why is this not working?

    Reply
    Page 3 of 3 | Prev |   1     2   3 |
    rcull | # 21 | 2010-03-11, 19:23 | Report

    try

    Code:
    if /sbin/ifconfig usb0 > /dev/null 2>&1
    then
        echo Running
    else
        echo Not Running
    fi
    Rick

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to rcull For This Useful Post:
    gobuki, lma

     
    lma | # 22 | 2010-03-11, 20:03 | Report

    Originally Posted by eitama View Post
    The thing that is not working is the * (asterisks).
    Try a pattern matching expression, like this:
    Code:
    if [ "${my#*bc}" != "$my" ]

    Edit | Forward | Quote | Quick Reply | Thanks

     
    gobuki | # 23 | 2010-03-11, 20:22 | Report

    Originally Posted by lma View Post
    Try a pattern matching expression, like this:
    Code:
    if [ "${my#*bc}" != "$my" ]
    Just to mention it: this is a bash feature and not supported by standard shells/busybox.
    You should really install a shell with better scripting support if you need regex and follow the countless shell-scripting tutorials on the net - unless maybe you want to deploy it elsewhere. Just make sure you're reading a tutorial for the right shell, since shell scripting != shell scripting.

    Edit | Forward | Quote | Quick Reply | Thanks

    Last edited by gobuki; 2010-03-11 at 20:29. Reason: added: if you need regex

     
    lma | # 24 | 2010-03-12, 05:38 | Report

    Originally Posted by gobuki View Post
    Just to mention it: this is a bash feature and not supported by standard shells/busybox.
    Wrong, try it!

    Edit | Forward | Quote | Quick Reply | Thanks

     
    gobuki | # 25 | 2010-03-12, 12:32 | Report

    You are right! I tried it and it works. I'm sorry. But I wonder where this is documented. I had a look at busybox.net and couldn't find anything about scripting or regular expressions. Not even in the manual page: http://busybox.net/downloads/BusyBox.html

    Care to give a keyword or link?

    Edit | Forward | Quote | Quick Reply | Thanks

     
    SubCore | # 26 | 2010-03-12, 13:39 | Report

    the shell built into busybox is the "Almquist shell" (or, more precisely, the debian ash variant.)

    your best bet for documentation would probably be this, that's the posix documentation for -compatible shells.

    Edit | Forward | Quote | Quick Reply | Thanks
    The Following 2 Users Say Thank You to SubCore For This Useful Post:
    gobuki, lma

     
    CowboyFromHell | # 27 | 2010-03-13, 01:14 | Report

    If you run linux on your PC and ash is installed:
    > man ash
    contains all of it. Unfortunately man and manpages are not preinstalled on N900 :°(

    Edit | Forward | Quote | Quick Reply | Thanks

     
    Page 3 of 3 | Prev |   1     2   3 |
vBulletin® Version 3.8.8
Normal Logout