함수 hostname()

gethostname
hostname
uname

1 Bash[ | ]

hostname
echo $HOSTNAME
uname -n

2 Cmd[ | ]

hostname
for /f "tokens=1" %a in ('hostname') do set myhostname=%a
echo %myhostname%

3 Go[ | ]

package main

import (
	"fmt"
	"os"
)

func main() {
	hostname, err := os.Hostname()
	if err != nil {
		panic(err)
	}
	fmt.Printf("Hostname: %s", hostname)
}

4 PHP[ | ]

echo gethostname();
echo php_uname('n');
echo getenv('HOSTNAME');
echo exec('hostname');
echo exec('echo $HOSTNAME');
echo exec('uname -n');

5 PowerShell[ | ]

[System.Net.Dns]::GetHostName()

6 Python[ | ]

import socket
print(socket.gethostname())
import subprocess
s = subprocess.Popen('hostname', shell=True, stdout=subprocess.PIPE).stdout.read().strip()
print( s )

7 Perl[ | ]

use Sys::Hostname;
my $host = hostname();
print $host . "\n";
print `hostname`;

8 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}