Hostname: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added a comment in the REXX section header, stating that the VALUE bif's output (as shown) is the same output as HOSTNAME. -- ~~~~) |
|||
Line 229: | Line 229: | ||
=={{header|Lasso}}== |
=={{header|Lasso}}== |
||
This will ge the hostname as reported by the web server |
|||
<lang Lasso>[web_request->httpHost]</lang> |
<lang Lasso>[web_request->httpHost]</lang> |
||
-> www.myserver.com |
|||
This will ge the hostname as reported by the system OS |
|||
<lang Lasso>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</lang> |
|||
-> mymachine.local |
|||
=={{header|Lua}}== |
=={{header|Lua}}== |