Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



Reply
 
Thread Tools Rate Thread Display Modes
Old 05-13-2009, 01:53 PM   #1
jpenguin
Prospect
 
Join Date: Jul 2008
Posts: 6
Determine PPC or Intel with ShellScipt

So, I have a /bin/sh shell scrip, and if the computer is a PPC-based one, I want it to execute one terminal command; but if the computer is Intel I want to execute a different terminal command
jpenguin is offline   Reply With Quote
Old 05-13-2009, 02:04 PM   #2
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Kansas City
Posts: 11,347
Code:
#!/bin/sh

x86=`system_profiler SPHardwareDataType | grep Intel -c`

if [[ $x86 == 1 ]]

then <insert intel command>

else <insert PPC commands>

fi

done
exit
That is a real simple way of doing it.
__________________
sudo make me a sammich

http://www.tlarkin.com

"It just told me what I already knew, that I'm a great and amazing guy, didn't I tell you baby, I'm Zaphod Beeblebrox."
tlarkin is offline   Reply With Quote
Old 05-13-2009, 02:12 PM   #3
jpenguin
Prospect
 
Join Date: Jul 2008
Posts: 6
thanks :-)
jpenguin is offline   Reply With Quote
Old 05-13-2009, 04:01 PM   #4
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Kansas City
Posts: 11,347
did it work?
__________________
sudo make me a sammich

http://www.tlarkin.com

"It just told me what I already knew, that I'm a great and amazing guy, didn't I tell you baby, I'm Zaphod Beeblebrox."
tlarkin is offline   Reply With Quote
Old 05-13-2009, 04:41 PM   #5
baf
MVP
 
Join Date: Jun 2007
Location: Skellefteċ, Sweden
Posts: 1,173
Or even:
uname -p
answers i386 for me but test and see what you get on other machines.
__________________
/Bengt-Arne Fjellner IT-Administrator Luleċ university, Sweden.
Some say: "You learn as long as you live".
My way: "You live as long as you learn".
baf is offline   Reply With Quote
Old 05-13-2009, 05:11 PM   #6
trevor
Moderator
 
Join Date: Jun 2003
Location: Boulder, CO USA
Posts: 19,550
Quote:
Originally Posted by baf
Or even:
uname -p
answers i386 for me but test and see what you get on other machines.

Code:
% uname -p
powerpc
...on my PowerBook G4 1 GHz Aluminum.

Trevor
trevor is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 06:08 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.