Related to How to detect and condition based on hostname . Answer in next post.
Asked
Active
Viewed 516 times
1
-
Isn't this a duplicate of the question you linked? – Marcel Krüger Nov 08 '21 at 22:51
-
Pretty sure it is a duplicate. The second answer in the linked post has the exact same answer. – user202729 Nov 09 '21 at 01:50
-
(besides, make the question an actual question.) – user202729 Nov 09 '21 at 01:50
-
Although this one may (or may not) be easier to search for? – user202729 Nov 09 '21 at 02:01
-
second answer there uses luacode and a test, not a print. it is of course based on it and similar, which is why I put the one-liner here. – ivo Welch Nov 09 '21 at 16:56
2 Answers
2
The hostname is available in LuaTeX through the socket library:
\directlua{
token.set_macro('hostname', socket.dns.gethostname())
}
Compiled on \hostname.
\bye
Marcel Krüger
- 34,151
0
\def\hostname{
\directlua{
tex.print(os.getenv('HOSTNAME'))
}}
Compiled: \today\ on \hostname.
but see Marcel's comment.
ivo Welch
- 3,766
-
4This doesn't work in general.
HOSTNAMEis not specified in any standard I am aware of and in many systems (including e.g. Arch Linux) not set by default. – Marcel Krüger Nov 08 '21 at 22:56 -
Windows doesn't know anything about it either (where it's
COMPUTERNAME) – Joseph Wright Dec 08 '21 at 17:02
