Results 1 to 3 of 3

Thread: [SOLVED] Need Help With Bash Script - CPU if else

  1. #1
    Join Date
    Mar 2006
    Beans
    1,123

    [SOLVED] Need Help With Bash Script - CPU if else

    Hi Guys,

    I wondered if someone could help me with my nearly completed bas script. The problem is that if/else does not work properly. Basically it should detect which cpu is used (intel or ppc) and with that info do the if/else.
    The command uname -p, if used on a Mac, will either output i386 for Intel and powerpc for PPC macs. The if part of the script is for the Intel (i386) and the else part is for PPC (powerpc).

    Right now the script does not work. Help is greatly appreciated!


    #!/bin/sh

    uname -p
    a=$?

    if test "$a" = "0";
    then
    pushd ~/Desktop; curl -C - -O http://fpdownload.macromedia.com/get...sx_ub.dmg.zip; popd
    pushd ~/Desktop; unzip install_flash_player_osx_ub.dmg.zip -d ~/Desktop/ && rm -r __MACOSX; popd
    pushd ~/Desktop; open /Users/180it/Desktop/Install\ Flash\ Player\ 9\ UB.dmg; popd
    rm ~/Desktop/install_flash_player_osx_ub.dmg.zip
    else
    pushd ~/Desktop; curl -O http://fpdownload.macromedia.com/get...layer_osx.dmg; popd
    pushd ~/Desktop; open install_flash_player_osx.dmg; popd
    fi
    Last edited by OffHand; September 3rd, 2008 at 02:03 PM.
    "I'd rather be hated for what I am, than loved for what I'm not."

  2. #2
    Join Date
    Nov 2007
    Location
    Atlanta, Georgia
    Beans
    494
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Need Help With Bash Script - CPU if else

    you probably want something like:

    Quote Originally Posted by OffHand View Post
    #!/bin/bash

    UNAME_P=`uname -p`

    if [ "i386" = "$UNAME_P" ]; then
    #this is what happens if uname -p return i386
    pushd ~/Desktop; curl -C - -O http://fpdownload.macromedia.com/get...sx_ub.dmg.zip; popd
    pushd ~/Desktop; unzip install_flash_player_osx_ub.dmg.zip -d ~/Desktop/ && rm -r __MACOSX; popd
    pushd ~/Desktop; open /Users/180it/Desktop/Install\ Flash\ Player\ 9\ UB.dmg; popd
    rm ~/Desktop/install_flash_player_osx_ub.dmg.zip
    else
    #this is what happens if uname -p does not return i386
    pushd ~/Desktop; curl -O http://fpdownload.macromedia.com/get...layer_osx.dmg; popd
    pushd ~/Desktop; open install_flash_player_osx.dmg; popd
    fi
    GNU/Linux>Windows

  3. #3
    Join Date
    Mar 2006
    Beans
    1,123

    Re: Need Help With Bash Script - CPU if else

    Thanks ilrudie but I had already found a working solution:

    #!/bin/sh

    if [[ `uname -p` == 'i386' ]]; then
    cd ~/Desktop; curl -C - -O http://fpdownload.macromedia.com/get...osx_ub.dmg.zip
    unzip install_flash_player_osx_ub.dmg.zip -d ~/Desktop/ && rm -r __MACOSX
    open /Users/180it/Desktop/Install\ Flash\ Player\ 9\ UB.dmg
    rm install_flash_player_osx_ub.dmg.zip
    else
    cd ~/Desktop; curl -O http://fpdownload.macromedia.com/get...player_osx.dmg
    open install_flash_player_osx.dmg
    exit
    fi
    Last edited by OffHand; September 4th, 2008 at 08:43 AM.
    "I'd rather be hated for what I am, than loved for what I'm not."

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
  •