如何使用 common lisp 确定操作系统和主机名?

发布于 2024-10-06 12:09:29 字数 175 浏览 0 评论 0原文

为了让我的 .sbclrc 文件在我使用的两台计算机上工作,我想要一种从 sbcl 中获取主机名和/或操作系统的方法。我知道我可以设置然后查找环境变量,但是有更直接的方法吗?

更新

我将问题更改为引用 common lisp,因为 Ken 的答案并不特定于 sbcl。

To get my .sbclrc file working on the two computers I use, I'd like a way to get the hostname and/or operating system from within sbcl. I know I could set and then look for an environment variable, but is there a more direct approach?

Update

I changed the question to refer to common lisp, since the answer from Ken is not specific to sbcl.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小伙你站住 2024-10-13 12:09:29

我将使用“环境”函数:

* (machine-instance)
"myhostname"
* (machine-type)
"X86-64"
* (machine-version)
"Intel(R) Core(TM)2 Quad CPU    Q6600  @ 2.40GHz"
* (software-type)
"Linux"
* (software-version)
"2.6.32-3-amd64"

I'd use the 'environment' functions:

* (machine-instance)
"myhostname"
* (machine-type)
"X86-64"
* (machine-version)
"Intel(R) Core(TM)2 Quad CPU    Q6600  @ 2.40GHz"
* (software-type)
"Linux"
* (software-version)
"2.6.32-3-amd64"
淡淡绿茶香 2024-10-13 12:09:29
* (require :sb-bsd-sockets)
("SB-BSD-SOCKETS" "SB-GROVEL" "ASDF")

* (use-package :sb-bsd-sockets)
T

* (host-ent-name (get-host-by-name "localhost"))
"myhost.mydomain.ext"

* (find :win32 *features*)
:WIN32

* (find :linux *features*)
NIL

编辑:我更喜欢@Ken 的解决方案。 +1。

* (require :sb-bsd-sockets)
("SB-BSD-SOCKETS" "SB-GROVEL" "ASDF")

* (use-package :sb-bsd-sockets)
T

* (host-ent-name (get-host-by-name "localhost"))
"myhost.mydomain.ext"

* (find :win32 *features*)
:WIN32

* (find :linux *features*)
NIL

EDIT: I like @Ken's solution better. +1.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文