如何在 Adob​​e AIR NativeProcess 中获取 Linux 中的主机名?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5605715/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:35:18  来源:igfitidea点击:

How to get host name in Linux in Adobe AIR NativeProcess?

linuxubuntuairfedoraflash-cs5

提问by Mudasir Bhutto

I am creating Adobe AIR Application (for Windows, Linux and MAC), which show machine's Internal IP, External IP and Host Name. I've done successfully on Windows. I got host name on Windows by opening the c:\windows\system32\hostname.exe application using the Native for process.

我正在创建 Adob​​e AIR 应用程序(适用于 Windows、Linux 和 MAC),它显示机器的内部 IP、外部 IP 和主机名。我已经在 Windows 上成功完成了。我通过使用 Native for 进程打开 c:\windows\system32\hostname.exe 应用程序获得了 Windows 上的主机名。

But I don't know that such type of hostname application file exists in Linux or not? If it really exists, then what is its path? How to get host name in Linux through opening any executable file or through any bash command?

但是我不知道Linux中是否存在这种类型的主机名应用程序文件?如果它真的存在,那么它的路径是什么?如何通过打开任何可执行文件或通过任何 bash 命令在 Linux 中获取主机名?

Thanks in advance.

提前致谢。

采纳答案by iehrlich

The best idea is to use

最好的主意是使用

'$ uname -n'

after using

使用后

'$ uname --help'

P.S.: and yes,

PS:是的,

$ which uname
/bin/uname

回答by Johnsyweb

The hostnamecommand appears in must Unixes.

hostname命令出现在 must Unixes 中。

Here's the path from a Mac (you mention this as one of your target platforms and I don't have a Linux host up at the moment):

这是来自 Mac 的路径(您提到这是您的目标平台之一,而我目前没有 Linux 主机):

% type hostname
hostname is /bin/hostname

You shouldn't need to hard-code the path, though... hostnameis usually within your ${PATH}environment variable (Q.E.D.). The same should be true for Windows.

您不需要对路径进行硬编码,但...hostname通常在您的${PATH}环境变量 (QED) 中。Windows 也应该如此。

回答by Subbu

Type in terminal:

输入终端:

hostname

You will get the hostname.

您将获得主机名。