Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
category:
- Networking and Web Interaction
from: http://rosettacode.org/wiki/Hostname
note: Programming environment operations

View file

@ -0,0 +1,4 @@
;Task:
Find the name of the host on which the routine is running.
<br><br>

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 @@
host name of (system info)

View file

@ -0,0 +1 @@
(system "hostname -f")

View file

@ -0,0 +1 @@
print sys\hostname

View file

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

View file

@ -0,0 +1,2 @@
for objItem in ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_ComputerSystem")
MsgBox, % "Hostname:`t" objItem.Name

View file

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

View file

@ -0,0 +1 @@
PRINT "Hostname: ", HOSTNAME$

View file

@ -0,0 +1 @@
Hostname

View file

@ -0,0 +1 @@
System.Net.Dns.GetHostName();

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,15 @@
identification division.
program-id. hostname.
data division.
working-storage section.
01 hostname pic x(256).
01 nullpos pic 999 value 1.
procedure division.
call "gethostname" using hostname by value length of hostname
string hostname delimited by low-value into hostname
with pointer nullpos
display "Host: " hostname(1 : nullpos - 1)
goback.
end program hostname.

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 ()
#+(or sbcl ccl) (machine-instance)
#+clisp (let ((s (machine-instance))) (subseq s 0 (position #\Space s)))
#-(or sbcl ccl 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 @@
hostname = System.hostname

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 @@
(system-name)

View file

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

View file

@ -0,0 +1 @@
printfn "%s" (System.Net.Dns.GetHostName())

View file

@ -0,0 +1,2 @@
USE: io.sockets
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,38 @@
program test_hostname
use, intrinsic :: iso_c_binding
implicit none
interface !to function: int gethostname(char *name, size_t namelen);
integer(c_int) function gethostname(name, namelen) bind(c)
use, intrinsic :: iso_c_binding, only: c_char, c_int, c_size_t
integer(c_size_t), value, intent(in) :: namelen
character(len=1,kind=c_char), dimension(namelen), intent(inout) :: name
end function gethostname
end interface
integer(c_int) :: status
integer,parameter :: HOST_NAME_MAX=255
character(kind=c_char,len=1),dimension(HOST_NAME_MAX) :: cstr_hostname
integer(c_size_t) :: lenstr
character(len=:),allocatable :: hostname
lenstr = HOST_NAME_MAX
status = gethostname(cstr_hostname, lenstr)
hostname = c_to_f_string(cstr_hostname)
write(*,*) hostname, len(hostname)
contains
! convert c_string to f_string
pure function c_to_f_string(c_string) result(f_string)
use, intrinsic :: iso_c_binding, only: c_char, c_null_char
character(kind=c_char,len=1), intent(in) :: c_string(:)
character(len=:), allocatable :: f_string
integer i, n
i = 1
do
if (c_string(i) == c_null_char) exit
i = i + 1
end do
n = i - 1 ! exclude c_null_char
allocate(character(len=n) :: f_string)
f_string = transfer(c_string(1:n), f_string)
end function c_to_f_string
end program test_hostname

View file

@ -0,0 +1,13 @@
' FB 1.05.0 Win64
' On Windows 10, the command line utility HOSTNAME.EXE prints the 'hostname' to the console.
' We can execute this remotely and read from its 'stdin' stream as follows:
Dim As String hostname
Open Pipe "hostname" For Input As #1
Input #1, hostname
Close #1
Print hostname
Print
Print "Press any key to quit"
Sleep

View file

@ -0,0 +1 @@
hostname

View file

@ -0,0 +1 @@
uname -n

View file

@ -0,0 +1 @@
callJava["java.net.InetAddress", "getLocalHost"].getHostName[]

View file

@ -0,0 +1,3 @@
include "NSLog.incl"
NSLog( @"%@", fn ProcessInfoHostName )
HandleEvents

View file

@ -0,0 +1,5 @@
Public Sub Main()
Print System.Host
End

View file

@ -0,0 +1,10 @@
package main
import (
"fmt"
"os"
)
func main() {
fmt.Println(os.Hostname())
}

View file

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

View file

@ -0,0 +1 @@
? NetName()

View file

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

View file

@ -0,0 +1,19 @@
module GetHostName where
import Foreign.Marshal.Array ( allocaArray0, peekArray0 )
import Foreign.C.Types ( CInt(..), CSize(..) )
import Foreign.C.String ( CString, peekCString )
import Foreign.C.Error ( throwErrnoIfMinus1_ )
getHostName :: IO String
getHostName = do
let size = 256
allocaArray0 size $ \ cstr -> do
throwErrnoIfMinus1_ "getHostName" $ c_gethostname cstr (fromIntegral size)
peekCString cstr
foreign import ccall "gethostname"
c_gethostname :: CString -> CSize -> IO CInt
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,2 @@
import java.net.InetAddress;
import java.net.UnknownHostException;

View file

@ -0,0 +1,4 @@
void printHostname() throws UnknownHostException {
InetAddress localhost = InetAddress.getLocalHost();
System.out.println(localhost.getHostName());
}

View file

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

View file

@ -0,0 +1 @@
var hn = exec("hostname", {retAll:true}).data.trim();

View file

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

View file

@ -0,0 +1 @@
_h

View file

@ -0,0 +1,7 @@
// version 1.1.4
import java.net.InetAddress
fun main(args: Array<String>) {
println(InetAddress.getLocalHost().hostName)
}

View file

@ -0,0 +1 @@
(net_adm:localhost)

View file

@ -0,0 +1 @@
[web_request->httpHost]

View file

@ -0,0 +1,35 @@
define host_name => thread {
data
public initiated::date, // when the thread was initiated. Most likely at Lasso server startup
private hostname::string // as reported by the servers hostname
public onCreate() => {
.reset
}
public reset() => {
if(lasso_version(-lassoplatform) >> 'Win') => {
protect => {
local(process = sys_process('cmd',(:'hostname.exe')))
#process -> wait
.hostname = string(#process -> readstring) -> trim&
#process -> close
}
else
protect => {
local(process = sys_process('/bin/hostname'))
#process -> wait
.hostname = string(#process -> readstring) -> trim&
#process -> close
}
}
.initiated = date(date -> format(`yyyyMMddHHmmss`)) // need to set format to get rid of nasty hidden fractions of seconds
.hostname -> size == 0 ? .hostname = 'undefined'
}
public asString() => .hostname
}
host_name

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,31 @@
implement Hostname;
include "sys.m"; sys: Sys;
include "draw.m";
Hostname: module {
init: fn(nil: ref Draw->Context, nil: list of string);
};
init(nil: ref Draw->Context, nil: list of string)
{
sys = load Sys Sys->PATH;
buf := array[Sys->ATOMICIO] of byte;
fd := sys->open("/dev/sysname", Sys->OREAD);
if(fd == nil)
die("Couldn't open /dev/sysname");
n := sys->read(fd, buf, len buf - 1);
if(n < 1)
die("Couldn't read /dev/sysname");
buf[n++] = byte '\n';
sys->write(sys->fildes(1), buf, n);
}
die(s: string)
{
sys->fprint(sys->fildes(2), "hostname: %s: %r", s);
raise "fail:errors";
}

View file

@ -0,0 +1,6 @@
sx = xtra("Shell").new()
if the platform contains "win" then
hostname = sx.shell_cmd("hostname", ["eol":RETURN]).line[1] -- win 7 or later
else
hostname = sx.shell_cmd("hostname", RETURN).line[1]
end if

View file

@ -0,0 +1 @@
answer the hostName

View file

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

View file

@ -0,0 +1,10 @@
Module Host {
\\ one way
Print computer$
\\ second way
Declare objNetwork "WScript.Network"
With objNetwork, "ComputerName" as cName$
Print cName$, cName$=Computer$
Declare objNetwork Nothing
}
Host

View file

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

View file

@ -0,0 +1 @@
echo -ag $host

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,4 @@
/* NetRexx */
options replace format comments java crossref savelog symbols binary
say InetAddress.getLocalHost.getHostName

View file

@ -0,0 +1 @@
(! "hostname")

View file

@ -0,0 +1,2 @@
import nativesockets
echo getHostName()

View file

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

View file

@ -0,0 +1,7 @@
MODULE HostName;
IMPORT
OS:ProcessParameters,
Out;
BEGIN
Out.Object("Host: " + ProcessParameters.GetEnv("HOSTNAME"));Out.Ln
END HostName.

View file

@ -0,0 +1,9 @@
use Net;
bundle Default {
class Hello {
function : Main(args : String[]) ~ Nil {
TCPSocket->HostName()->PrintLine();
}
}
}

View file

@ -0,0 +1 @@
NSLog(@"%@", [[NSProcessInfo processInfo] hostName]);

View file

@ -0,0 +1 @@
2010-09-16 16:20:00.000 Playground[1319:a0f] sierra117.local // Hostname is sierra117.local.

View file

@ -0,0 +1 @@
uname().nodename

View file

@ -0,0 +1 @@
say .oleObject~new('WScript.Network')~computerName

View file

@ -0,0 +1 @@
say value('COMPUTERNAME',,'environment')

View file

@ -0,0 +1 @@
address command 'hostname -f'

View file

@ -0,0 +1 @@
address command "echo $HOSTNAME"

View file

@ -0,0 +1,7 @@
/* Rexx */
address command "echo $HOSTNAME | rxqueue"
address command "hostname -f | rxqueue"
loop q_ = 1 while queued() > 0
parse pull hn
say q_~right(2)':' hn
end q_

View file

@ -0,0 +1,8 @@
/* Rexx */
qq = .rexxqueue~new()
address command "echo $HOSTNAME | rxqueue"
address command "hostname -f | rxqueue"
loop q_ = 1 while qq~queued() > 0
hn = qq~pull()
say q_~right(2)':' hn
end q_

View file

@ -0,0 +1 @@
{System.showInfo {OS.getHostByName 'localhost'}.name}

View file

@ -0,0 +1,2 @@
str = externstr("hostname")[1];
str = externstr("uname -n")[1];

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,4 @@
SET serveroutput on
BEGIN
DBMS_OUTPUT.PUT_LINE(UTL_INADDR.GET_HOST_NAME);
END;

View file

@ -0,0 +1,8 @@
Program HostName;
uses
unix;
begin
writeln('The name of this computer is: ', GetHostName);
end.

View file

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

View file

@ -0,0 +1,9 @@
(notonline)-->
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (system_exec, file i/o)</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">tmp</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"hostname.txt"</span><span style="color: #0000FF;">,</span>
<span style="color: #000000;">cmd</span> <span style="color: #0000FF;">=</span> <span style="color: #008080;">iff</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">platform</span><span style="color: #0000FF;">()=</span><span style="color: #004600;">WINDOWS</span><span style="color: #0000FF;">?</span><span style="color: #008000;">"hostname"</span><span style="color: #0000FF;">:</span><span style="color: #008000;">"uname -n"</span><span style="color: #0000FF;">)</span>
<span style="color: #0000FF;">{}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">system_exec</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%s &gt; %s"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">cmd</span><span style="color: #0000FF;">,</span><span style="color: #000000;">tmp</span><span style="color: #0000FF;">}),</span><span style="color: #000000;">4</span><span style="color: #0000FF;">)</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">host</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">trim</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">get_text</span><span style="color: #0000FF;">(</span><span style="color: #000000;">tmp</span><span style="color: #0000FF;">))</span>
<span style="color: #0000FF;">{}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">delete_file</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"hostname.txt"</span><span style="color: #0000FF;">)</span>
<span style="color: #0000FF;">?</span><span style="color: #000000;">host</span>
<!--

View file

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

View file

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

View file

@ -0,0 +1,5 @@
import System;
int main(){
write(gethostname() + "\n");
}

View file

@ -0,0 +1 @@
lvars host = sys_host_name();

View file

@ -0,0 +1 @@
HOST NAME TO hostname$

View file

@ -0,0 +1 @@
HOST NAME ipAddress& TO hostname$

Some files were not shown because too many files have changed in this diff Show more