Results 1 to 7 of 7

Thread: bash script help

  1. #1
    Join Date
    Sep 2009
    Location
    UK
    Beans
    435
    Distro
    Ubuntu 10.04 Lucid Lynx

    bash script help

    didn think i would be asking for help with a script anytime soon but...

    I have a script that i run to choose a profile in firefox;

    Code:
    #!/bin/bash
    
    checkEth0=$(ifconfig eth0 | grep inet)
    if [ -n "$checkEth0" ]; then
        firefox -P "work"
    else
        firefox -P "home"
    fi
    (alias firefox="script.sh")

    this works from terminal, but from a link in the menu it does not... (ifconfig is always null... so i always get "home" profile)...

    this is obviously effected by an environment variable, which and why?
    My personal website with blog n apps
    http://www.mikejonesey.co.uk/

  2. #2
    Join Date
    Oct 2008
    Beans
    3,509

    Re: bash script help

    Are you using eth0?
    For some reason mine uses eth2.

  3. #3
    Join Date
    Feb 2008
    Beans
    5,636

    Re: bash script help

    Try making the link in the menu
    Code:
    bash /path/script
    instead of
    Code:
    /path/script

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Beans
    435
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: bash script help

    yes i am, (it would not work from terminal otherwise, it only does not work from the menu shortcut...)
    My personal website with blog n apps
    http://www.mikejonesey.co.uk/

  5. #5
    Join Date
    Sep 2009
    Location
    UK
    Beans
    435
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: bash script help

    @TeoBigusGeekus

    just tried that, no change... (would have been set anyway by the #!/bin/bash at top of script...)

    i'll try a env >> script see if that makes any difference...
    My personal website with blog n apps
    http://www.mikejonesey.co.uk/

  6. #6
    Join Date
    Sep 2009
    Location
    UK
    Beans
    435
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: bash script help

    env >> script makes it work but where what and why... i'll trial and error untill i find out... will post back...
    My personal website with blog n apps
    http://www.mikejonesey.co.uk/

  7. #7
    Join Date
    Sep 2009
    Location
    UK
    Beans
    435
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: bash script help

    it was the PATH environment variable that pulled it together...

    changing the script to...

    Code:
    #!/bin/bash
    
    checkEth0=$(/sbin/ifconfig eth0 | /bin/grep inet)
    if [ -n "$checkEth0" ]; then
        /usr/bin/firefox -P "work"
    else
        /usr/bin/firefox -P "home"
    fi
    ensures it works from anywhere... (adding the paths to ifconfig and grep...)

    thanks for replies...
    My personal website with blog n apps
    http://www.mikejonesey.co.uk/

Bookmarks

Posting Permissions

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