Results 1 to 7 of 7

Thread: Some scripting Problems

  1. #1
    Join Date
    Feb 2013
    Beans
    25

    Some scripting Problems

    Hi there, so I have an almost perfect running script, but at one point there is an If statement, in which I'm declaring a variable
    [
    if [ "$(lspci | grep -i vga | grep -i -o nvidia)" != "" ]
    then
    (line 16) $pkg = nvidia
    ]

    Now I get always the error :" line 16: =: command not found "
    tried using the == or putting nvidia in ""

    hope someone has an Idea how to maybe fix it

    greetz
    thedawg

  2. #2
    Join Date
    Jan 2009
    Location
    Denmark
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Some scripting Problems

    Quote Originally Posted by thedawg View Post
    Hi there, so I have an almost perfect running script, but at one point there is an If statement, in which I'm declaring a variable
    [
    if [ "$(lspci | grep -i vga | grep -i -o nvidia)" != "" ]
    then
    (line 16) $pkg = nvidia
    ]

    Now I get always the error :" line 16: =: command not found "
    tried using the == or putting nvidia in ""

    hope someone has an Idea how to maybe fix it

    greetz
    thedawg
    Wouldn't a better way be.

    Code:
    if [ ! -z "$(lspci | grep -io -e "vga" -e "nvidia" )" ]
    then
    #Something
    fi
    -z means. String is null
    http://tldp.org/LDP/abs/html/comparison-ops.html

    Not a scripting expert so if anyone has input to my suggestion. Please don't hold back
    Last edited by Drenriza; February 27th, 2013 at 09:57 AM.

  3. #3
    Join Date
    Feb 2013
    Beans
    25

    Re: Some scripting Problems

    Sorry my fault, of course I've closed it in the end
    didn't think the rest would be needed.
    Here's the whole if statement where the failure appears

    if [ "$(lspci | grep -i vga | grep -i -o nvidia)" != "" ]
    then
    $pkg = nvidia
    apt-get install nvidia-current nvidia-current-updates
    else if
    [ "$(lspci | grep -i vga | grep -i -o intel)" != "" ]
    then
    $pkg = intel
    else
    $pkg = ati

    fi
    fi

  4. #4
    Join Date
    May 2006
    Location
    Boston
    Beans
    1,918
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Some scripting Problems

    try this, and please use code tags:

    change "(line 16) $pkg = nvidia" to "pkg = nvidia";

    you are assigning a variable not calling it, therefore you do not need the "$" in fron of it

    blog
    Donations BTC : 12FwoB7uAM5FnweykpR1AEEDVFaTLTYFkS
    DOUBLEPLUSGOOD!!

  5. #5
    Join Date
    Feb 2013
    Beans
    25

    Re: Some scripting Problems

    Did not work

    still getting

    " line 16: pkg = nvidia: command not found "

  6. #6
    Join Date
    May 2006
    Location
    Boston
    Beans
    1,918
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Some scripting Problems

    Quote Originally Posted by thedawg View Post
    Did not work

    still getting

    " line 16: pkg = nvidia: command not found "
    Code:
    if [ "$(lspci | grep -i vga | grep -i -o nvidia)" != "" ]
    then
    pkg="nvidia"
    apt-get install nvidia-current nvidia-current-updates
    else if
    [ "$(lspci | grep -i vga | grep -i -o intel)" != "" ]
    then
    pkg="intel"
    else
    pkg="ati"
    
    fi
    fi
    bash complains about the empty spaces arount "="
    Last edited by fdrake; February 27th, 2013 at 10:12 AM.

    blog
    Donations BTC : 12FwoB7uAM5FnweykpR1AEEDVFaTLTYFkS
    DOUBLEPLUSGOOD!!

  7. #7
    Join Date
    Feb 2013
    Beans
    25

    Re: Some scripting Problems

    That's it,
    thanks fdrake

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
  •