This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1 @@
Find the name of the host on which the routine is running.

4
Task/Hostname/1META.yaml Normal file
View file

@ -0,0 +1,4 @@
---
category:
- Networking and Web Interaction
note: Programming environment operations

View file

@ -0,0 +1,3 @@
STRING hostname;
get(read OF execve child pipe("/bin/hostname","hostname",""), hostname);
print(("hostname: ", hostname, new line))

View file

@ -0,0 +1,2 @@
$ awk 'BEGIN{print ENVIRON["HOST"]}'
E51A08ZD

View file

@ -0,0 +1,7 @@
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Sockets;
procedure Demo is
begin
Put_Line (GNAT.Sockets.Host_Name);
end Demo;

View file

@ -0,0 +1 @@
println (System.hostname)

View file

@ -0,0 +1 @@
MsgBox % A_ComputerName

View file

@ -0,0 +1,4 @@
INSTALL @lib$+"SOCKLIB"
PROC_initsockets
PRINT "hostname: " FN_gethostname
PROC_exitsockets

View file

@ -0,0 +1,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <unistd.h>
int main(void)
{
char name[_POSIX_HOST_NAME_MAX + 1];
return gethostname(name, sizeof name) == -1 || printf("%s\n", name) < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}

View file

@ -0,0 +1 @@
(.. java.net.InetAddress getLocalHost getHostName)

View file

@ -0,0 +1 @@
java -cp clojure.jar clojure.main -e "(.. java.net.InetAddress getLocalHost getHostName)"

View file

@ -0,0 +1,2 @@
os = require 'os'
console.log os.hostname()

View file

@ -0,0 +1,4 @@
(defun get-host-name ()
#+sbcl (machine-instance)
#+clisp (let ((s (machine-instance))) (subseq s 0 (position #\Space s)))
#-(or sbcl clisp) (error "get-host-name not implemented"))

View file

@ -0,0 +1,8 @@
(cffi:defcfun ("gethostname" c-gethostname) :int
(buf :pointer) (len :unsigned-long))
(defun get-hostname ()
(cffi:with-foreign-object (buf :char 256)
(unless (zerop (c-gethostname buf 256))
(error "Can't get hostname"))
(values (cffi:foreign-string-to-lisp buf))))

View file

@ -0,0 +1,2 @@
BOA> (get-hostname)
"aurora"

View file

@ -0,0 +1,5 @@
import std.stdio, std.socket;
void main() {
writeln(Socket.hostName());
}

View file

@ -0,0 +1,16 @@
program ShowHostName;
{$APPTYPE CONSOLE}
uses Windows;
var
lHostName: array[0..255] of char;
lBufferSize: DWORD;
begin
lBufferSize := 256;
if GetComputerName(lHostName, lBufferSize) then
Writeln(lHostName)
else
Writeln('error getting host name');
end.

View file

@ -0,0 +1 @@
makeCommand("hostname")()[0].trim()

View file

@ -0,0 +1 @@
Host = net_adm:localhost().

View file

@ -0,0 +1 @@
host-name

View file

@ -0,0 +1,3 @@
include unix/socket.fs
hostname type

View file

@ -0,0 +1,5 @@
program HostTest
character(len=128) :: name
call hostnm(name)
print *, name
end program HostTest

View file

@ -0,0 +1,11 @@
package main
import (
"fmt"
"os"
)
func main() {
host, _ := os.Hostname()
fmt.Printf("hostname: %s\n", host)
}

View file

@ -0,0 +1 @@
println InetAddress.localHost.hostName

View file

@ -0,0 +1,3 @@
import Network.BSD
main = do hostName <- getHostName
putStrLn hostName

View file

@ -0,0 +1 @@
hostname = GETENV('computername')

View file

@ -0,0 +1,3 @@
procedure main()
write(&host)
end

View file

@ -0,0 +1,13 @@
NB. Load the socket libraries
load 'socket'
coinsert 'jsocket'
NB. fetch and implicitly display the hostname
> {: sdgethostname ''
NB. If fetching the hostname is the only reason for loading the socket libraries,
NB. and the hostname is fetched only once, then use a 'one-liner' to accomplish it:
> {: sdgethostname coinsert 'jsocket' [ load 'socket'

View file

@ -0,0 +1,9 @@
import java.net.*;
class DiscoverHostName {
public static void main(final String[] args) {
try {
System.out.println(InetAddress.getLocalHost().getHostName());
} catch (UnknownHostException e) { // Doesn't actually happen, but Java requires it be handled.
}
}
}

View file

@ -0,0 +1,3 @@
var network = new ActiveXObject('WScript.Network');
var hostname = network.computerName;
WScript.echo(hostname);

View file

@ -0,0 +1,8 @@
lpBuffer$=Space$(128) + Chr$(0)
struct SIZE,sz As Long
SIZE.sz.struct=Len(lpBuffer$)
calldll #kernel32, "GetComputerNameA",lpBuffer$ as ptr, SIZE as struct, result as Long
CurrentComputerName$=Trim$(Left$(lpBuffer$, SIZE.sz.struct))
print CurrentComputerName$

View file

@ -0,0 +1,2 @@
socket = require "socket"
print( socket.dns.gethostname() )

View file

@ -0,0 +1 @@
[failed,hostname] = system('hostname')

View file

@ -0,0 +1 @@
Write $Piece($System,":")

View file

@ -0,0 +1 @@
Sockets:-GetHostName()

View file

@ -0,0 +1 @@
$MachineName

View file

@ -0,0 +1,7 @@
MODULE Hostname EXPORTS Main;
IMPORT IO, OSConfig;
BEGIN
IO.Put(OSConfig.HostName() & "\n");
END Hostname.

View file

@ -0,0 +1 @@
echo $_SERVER['HTTP_HOST'];

View file

@ -0,0 +1 @@
echo php_uname('n');

View file

@ -0,0 +1 @@
echo gethostname();

View file

@ -0,0 +1,3 @@
use Sys::Hostname;
$name = hostname;

View file

@ -0,0 +1 @@
(call 'hostname)

View file

@ -0,0 +1 @@
(in '(hostname) (line T))

View file

@ -0,0 +1,2 @@
import socket
host = socket.gethostname()

View file

@ -0,0 +1 @@
Sys.info()[["nodename"]]

View file

@ -0,0 +1 @@
system("hostname", intern = TRUE)

View file

@ -0,0 +1,2 @@
env_var <- ifelse(.Platform$OS.type == "windows", "COMPUTERNAME", "HOSTNAME")
Sys.getenv(env_var)

View file

@ -0,0 +1,2 @@
say value('COMPUTERNAME',,"ENVIRONMENT")
say value('OS',,"ENVIRONMENT")

View file

@ -0,0 +1,2 @@
say value('COMPUTERNAME',,"SYSTEM")
say value('OS',,"SYSTEM")

View file

@ -0,0 +1 @@
say userid()

View file

@ -0,0 +1 @@
'VER' /*this passes the VER command to the MS DOS system. */

View file

@ -0,0 +1,6 @@
/* Rexx */
address command "hostname -f" with output stem hn.
do q_ = 1 to hn.0
say hn.q_
end q_
exit

View file

@ -0,0 +1,3 @@
#lang racket/base
(require mzlib/os)
(gethostname)

View file

@ -0,0 +1,2 @@
require 'socket'
host = Socket.gethostname

View file

@ -0,0 +1 @@
println(java.net.InetAddress.getLocalHost.getHostName)

View file

@ -0,0 +1,2 @@
(use posix)
(get-host-name)

View file

@ -0,0 +1 @@
(gethostname)

View file

@ -0,0 +1 @@
OperatingSystem getHostName

View file

@ -0,0 +1 @@
set hname [info hostname]