如何使用所有的Unix环境变量? [英] How to use all the Unix environment variables?
问题描述
使用Java(JSch API)我试图在远程机器上执行Unix命令。现在,要成功执行此命令,我需要使用已经设置在远程框上的所有环境变量。
Using Java (JSch API) I am trying to execute an Unix command on a remote machine. Now, to successfully execute this command I need to use all the environment variables already set on the remote box.
我可以使用 export< variable>
命令在运行时设置变量。但是,由于这些变量的数量相当大,我想知道在运行时是否有更好的方法来使用变量。
I can use export <variable>
command to set the variables on runtime. But as the number of such variables is quite large I am wondering if there is any better way to use the variables in runtime.
任何人都可以帮忙或者应该多说一点吗?
Can anyone help please or should I explain a bit more?
推荐答案
p>您可以将变量保存到文件中:
You can save variables into a file:
set > /tmp/vars
echo "A=120" >> /tmp/vars
然后在脚本中使用点import变量,如下所示: p>
and then "import" the variables with dot in a script like this:
set -a
. /tmp/vars
mycommand
这篇关于如何使用所有的Unix环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!