确定系统操作系统的最佳方法是什么? [英] what is the best way to determine system OS?

查看:86
本文介绍了确定系统操作系统的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。


我正在写一个小应用程序我想跨平台

(debian,RH,Fedora,Solaris, AIX等)


最初我决定查看uname返回的内容,因为我认为它不会超出Linux或SunOS等的细节。 。


最近我了解到FC3打破了我的脚本,所以我需要能够确定不仅仅是Linux了。但是确切地知道运行

脚本的是什么。


确定这个的最佳方法是什么?


谢谢!


googleboy

Hi there.

I am writing a little app tha tI would like to make cross-platform
(debian, RH, Fedora, Solaris, AIX, etc)

Originally I decided to check what uname returned, as I didn''t think it
mattered beyond the detail of Linux or SunOS etc.

Recently I have learned that FC3 breaks my script, so I need to be
able to determine not simply "Linux" but to know exactly what unix the
script is being run on.

What is the best way to determine this?

Thanks!

googleboy

推荐答案

怎么样的popen'' uname -r''?


问候,


Philippe

googleboy写道:
How about popen of ''uname -r'' ?

Regards,

Philippe
googleboy wrote:
你好。

我正在写一个小应用程序,我想制作跨平台
(debian,RH,Fedora,Solaris,AIX等)

最初我决定查看uname返回的内容,因为我认为它不会超出Linux或SunOS等的细节。

最近我学会了FC3破坏了我的脚本,所以我需要能够确定不仅仅是Linux。但要确切知道正在运行的是什么unix。

确定这个的最佳方法是什么?

谢谢!

googleboy
Hi there.

I am writing a little app tha tI would like to make cross-platform
(debian, RH, Fedora, Solaris, AIX, etc)

Originally I decided to check what uname returned, as I didn''t think it
mattered beyond the detail of Linux or SunOS etc.

Recently I have learned that FC3 breaks my script, so I need to be
able to determine not simply "Linux" but to know exactly what unix the
script is being run on.

What is the best way to determine this?

Thanks!

googleboy






" googleboy" <我的****** @ yahoo.com>写道:
"googleboy" <my******@yahoo.com> writes:
你好。

我正在写一个小应用程序,我想制作跨平台
(debian,RH,Fedora ,Solaris,AIX等)

最初我决定查看uname返回的内容,因为我认为它不会超出Linux或SunOS等的细节。

最近我了解到FC3打破了我的脚本,所以我需要能够确定不仅仅是Linux。但要确切知道运行的是什么unix。
Hi there.

I am writing a little app tha tI would like to make cross-platform
(debian, RH, Fedora, Solaris, AIX, etc)

Originally I decided to check what uname returned, as I didn''t think it
mattered beyond the detail of Linux or SunOS etc.

Recently I have learned that FC3 breaks my script, so I need to be
able to determine not simply "Linux" but to know exactly what unix the
script is being run on.




无论如何,检查系统名称是构建便携式的错误方法

计划。首先,正如您所发现的那样,新系统无法正常工作。另一方面,对现有系统的升级可能会破坏物品




您应该做的是检查如何使用您的功能
想要。如果你看一个典型的autoconf脚本,你会看到它通过库,包含文件和各种目录来查看

子程序,定义和命令。这就是这个想法,但没有

知道你正在寻找哪些功能,我不能说你将如何检查它们.B br />

这需要更多的时间来编写,但会产生更强大的代码。对于

实例,如果某些分布改变其中一个功能以模仿

更好你已经支持的发行,而不是你的脚本

打破,它只会工作。这比你必须教你的脚本如何区分版本的发行版要好得多。


< mike

- -

Mike Meyer< mw*@mired.org> http://www.mired.org/home/mwm/

独立的WWW / Perforce / FreeBSD / Unix顾问,电子邮件以获取更多信息。



Anyway, checking the system name is the wrong way to build portable
programs. For one thing, as you''ve discovered, new systems won''t work
properly. For another, upgrades to existing systems may break things
as well.

What you should do instead is check on how to use the features you
want. If you watch a typical autoconf script, you''ll see it groveling
through libraries, include files, and various directories looking for
subroutines, defines and commands. That''s the idea, but without
knowing which features you''re looking for, I can''t say how you would
check for them.

This takes more time to write, but results in more robust code. For
instance, if some distribution changes one of the features to mimic a
"better" distribution that you already support, instead of your script
breaking, it''ll just work. This is much better than having to teach
your script how to distinguish between versions of distributions.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.


googleboy写道:
googleboy wrote:
你好。

我正在写一个小应用程序,我想制作跨平台的
(debian,RH,Fedora,Solaris,AIX等)

最初我决定查看uname返回的内容,因为我认为它不会超出Linux或SunOS等的细节。

最近我了解到FC3打破了我的脚本,所以我需要能够确定的不仅仅是Linux。但要确切知道运行的是什么unix。

确定这个的最佳方法是什么?
Hi there.

I am writing a little app tha tI would like to make cross-platform
(debian, RH, Fedora, Solaris, AIX, etc)

Originally I decided to check what uname returned, as I didn''t think it
mattered beyond the detail of Linux or SunOS etc.

Recently I have learned that FC3 breaks my script, so I need to be
able to determine not simply "Linux" but to know exactly what unix the
script is being run on.

What is the best way to determine this?




看看平台模块。


-

Robert Kern
rk *** @ ucsd.edu


在草地长高的地狱里

是梦的坟墓允许死亡。

- Richard Harter



Look at the platform module.

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter


这篇关于确定系统操作系统的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆