FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 01-03-2012, 04:53 PM
Peng Yu
 
Default Command to tell whether it ubuntu and mac

Hi,

I want to make a script work for both mac and ubuntu. Is there a
command that I can tell me whether I'm on an ubuntu or on a mac?

--
Regards,
Peng

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 01-03-2012, 06:55 PM
Avi Greenbury
 
Default Command to tell whether it ubuntu and mac

Peng Yu wrote:

> I want to make a script work for both mac and ubuntu. Is there a
> command that I can tell me whether I'm on an ubuntu or on a mac?

Several. A mac wont, for example, have any files of the
form /boot/vmlinuz, or a /proc.

uname is probably the most appropriate one - OSX uses a Darwin kernel
while Ubuntu uses a Linux one.

What are you writing the script in? There's a few utilities that can
help with the various changes you'll need to make to your assumptions
for different systems.

--
Avi

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 01-03-2012, 08:42 PM
Peng Yu
 
Default Command to tell whether it ubuntu and mac

On Tue, Jan 3, 2012 at 1:55 PM, Avi Greenbury <lists@avi.co> wrote:
> Peng Yu wrote:
>
>> I want to make a script work for both mac and ubuntu. Is there a
>> command that I can tell me whether I'm on an ubuntu or on a mac?
>
> Several. A mac wont, for example, have any files of the
> form /boot/vmlinuz, or a /proc.
>
> uname is probably the most appropriate one - OSX uses a Darwin kernel
> while Ubuntu uses a Linux one.
>
> What are you writing the script in? There's a few utilities that can
> help with the various changes you'll need to make to your assumptions
> for different systems.

bash. So I guess the two approaches just you suggested are sufficient.
Let me know if there are additional ones that are good with bash.

--
Regards,
Peng

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 01-04-2012, 01:39 AM
Hal Burgiss
 
Default Command to tell whether it ubuntu and mac

On Tue, Jan 3, 2012 at 4:42 PM, Peng Yu <pengyu.ut@gmail.com> wrote:


On Tue, Jan 3, 2012 at 1:55 PM, Avi Greenbury <lists@avi.co> wrote:

> Peng Yu wrote:

>

>> I want to make a script work for both mac and ubuntu. Is there a

>> command that I can tell me whether I'm on an ubuntu or on a mac?

>

uname would probably give you what you need.
*$ uname -oGNU/Linux
On my Macbook, I get something like 'Darwin'. YMMV.


$ uname -o |grep Linux>/dev/null && is_linux=true || is_linux=false$ echo $is_linuxtrue
--*Hal

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 05:08 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org