Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在unix中隐藏grep过程中显示的密码_Java_Shell_Unix - Fatal编程技术网

Java 如何在unix中隐藏grep过程中显示的密码

Java 如何在unix中隐藏grep过程中显示的密码,java,shell,unix,Java,Shell,Unix,下面是一段代码 stringpassword=enigma.decrypt(propFile.getProperty(“密码”); 字符串ptr_sec=presto_cli_path+“/presto--server”+presto_https_server+“--keystore path”+keystore_path+“--keystore password”+keystore_password+“--catalog”+presto_catalog+“--schema”+presto_sc

下面是一段代码

stringpassword=enigma.decrypt(propFile.getProperty(“密码”);
字符串ptr_sec=presto_cli_path+“/presto--server”+presto_https_server+“--keystore path”+keystore_path+“--keystore password”+keystore_password+“--catalog”+presto_catalog+“--schema”+presto_schema+“--user”+presto_user+“-f”+queryFile+“--outputFromat+--password password;
进程p_sec=Runtime.getRuntime().exec(新字符串[]{“bash”,“-c”,ptr_sec});
上述代码在JAVA JAR中可用。当进程运行时以及当我使用grep时

ps -ef|grep criskrep|grep presto
它显示包含密码的完整字符串


请帮助解决此问题。

那么您想在shell中隐藏密码,而不是在Java中?在Java中,我不打印密码。这个问题与java源代码本身有关吗?与选项“-c”有关吗?在类似POSIX的系统上运行的进程的命令行是公共知识。不要把任何所谓的秘密信息放在那里。找到一种以其他方式(如环境变量或具有适当权限的文件)传递机密信息的方法:(是否有其他方法解决此问题。例如,一旦构造字符串,将详细信息放入文件中,然后从“exec”执行文件)方法?您可以使用一些加密软件对其进行加密,并将加密值存储在jar中。然后在需要之前在代码中对其进行解密。这并不完美,但它会对
grep
隐藏密码。