Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing environment variables in arguments #118

Open
ChrisHuebsch-FLIG opened this issue Apr 5, 2024 · 3 comments
Open

Accessing environment variables in arguments #118

ChrisHuebsch-FLIG opened this issue Apr 5, 2024 · 3 comments

Comments

@ChrisHuebsch-FLIG
Copy link

I have a small suggestion, which would help me a lot in using jmxterm for daily use.

I have a service running with several beans. All those beans expose a jmx-interface.

They support some operation to set a value.

I need to set the value to a subset of those beans.

For this I have a config file, which I execute with the "-i" command switch.

But the config files are static. I need a possibility to "inject" some variable content to the file, because the operation argument is different each time.

Certainly, I could rewrite the file every time with sed/awk/grep or something like that.

What I wish I had was some placeholder method in the command syntax. Like so:

run -b com.xxx.yyy.zzz:name=hello,type=Handler setDateTime "%ddd%"

When the program runs, it should replace "%ddd%" by whatever content is in that specific environment variable named ddd.

I added this for testing to ValueFormat/parseValue, but I am not sure if that is the proper place. Perhaps this could also be part of that jcli library (or it might even already be, but it's not used???)

@nyg
Copy link
Contributor

nyg commented Apr 5, 2024

I don't know if this fits your use case but something like this could be done:

$ MYVAR=somevalue; echo "open 4302\nbean edu.self.nyg.example.jmx.app:Lorem=ipsum,foo=Bar\nrun executeOperation $MYVAR\nclose\nbye" | java -jar target/jmxterm-1.0.4-uber.jar
Apr 05, 2024 10:43:41 AM org.jline.utils.Log logr
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
Delete /Users/user/.jmxterm_history if you encounter error right after launching me.
Welcome to JMX terminal. Type "help" for available commands.
$>open 4302#Connection to 4302 is opened
$>bean edu.self.nyg.example.jmx.app:Lorem=ipsum,foo=Bar#bean is set to edu.self.nyg.example.jmx.app:Lorem=ipsum,foo=Bar
$>run executeOperation somevalue#calling operation executeOperation of mbean edu.self.nyg.example.jmx.app:Lorem=ipsum,foo=Bar with params [somevalue]
#operation returns:
null
$>close#disconnected
$>bye#bye

@ChrisHuebsch-FLIG
Copy link
Author

That is certainly a good way to get to the variable content.

But I need to set the same value for several beans. That would require several starts of the jmxterm and a rather complex batch script to do that.

But yes, that would work. An environment expansion would be more convenient, though ;-)

@nyg
Copy link
Contributor

nyg commented Apr 5, 2024

Hmm yes, indeed, that could be a nice feature.

However, as you can see, I'm just another user :). I've made two other PRs but they have not been merged (though approved).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants