英文:
How can I read first host name in jboss-cli
问题
I'm writing a jboss-cli script which manipulates the servers in a host.xml file, however I'm not able to retrieve the host name (the name has to be dynamic).
I am able to get a list of the current host names with the following
set host=`:read-children-names(child-type=host)`
but the value returned is a list, not a single item.
echo $host
["master"]
Is there a way to get the first host in the list? Or is there an alternative way to read the current host? (we're never expecting more than one)
Thanks if you can help!
EDIT: My workaround was to use the COMPUTERNAME environment variable (Wildfly is running on Windows), knowing that the Wildfly host name should always be the same as the computer name. (This customer's servers are all set up in this way). However, I would prefer to do this properly.
英文:
I'm writing a jboss-cli script which manipulates the servers in a host.xml file, however I'm not able to retrieve the host name (the name has to be dynamic).
I am able to get a list of the current host names with the following
set host=`:read-children-names(child-type=host)`
but the value returned is a list, not a single item.
echo $host
["master"]
Is there a way to get the first host in the list? Or is there an alternative way to read the current host? (we're never expecting more than one)
Thanks if you can help!
EDIT: My workaround was to use the COMPUTERNAME environment variable (Wildfly is running on Windows), knowing that the Wildfly host name should always be the same as the computer name. (This customer's servers are all set up in this way). However, I would prefer to do this properly.
答案1
得分: 1
翻译好的内容如下:
给定您想获取正在使用的主机名,您可以使用 local-host-name
属性。
set host=`:read-attribute(name=local-host-name)`
这将产生类似以下的输出:
[domain@embedded /] echo $host
primary
英文:
Given you want to get the host name in use, you can use the local-host-name
attribute.
set host=`:read-attribute(name=local-host-name)`
That produces something like:
[domain@embedded /] echo $host
primary
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论