2012-09-27 112 views
0

我有其中i已禁用用於密碼字段呼應擊中以下命令後的應用程序:掩蔽密碼輸入從控制檯:爪哇與nohup命令

java -cp testJar.jar testClassFileInJar username 

其中用戶名是提供給主參數類testClassFileInJar的方法。點擊回車後,系統會提示輸入密碼。當我嘗試下面的命令我不能讓它運行,並且java1.out文件也是空的。

nohup java -cp testJar.jar testClassFileInJar username & > java1.out 

請建議。總而言之,我需要在java1.out文件中執行日誌記錄,並使用nohup命令來使用此java命令。

我用的主要方法如下代碼:

Console console = System.console(); 
String userName = args[0]; 
String password = String.valueOf(console.readPassword("Password: ")); 
//other code logic for processing username and password 

回答

0

我試着用nohup的,但毫無效果。然後我將記錄器配置到應用程序(java.util.logging.Logger)並使用screen運行以下命令。

java -cp testJar.jar testClassFileInJar username 

在屏幕中,此命令將提示輸入密碼。

只是滿足我的要求:)

0

嘗試,而不是執行以下操作:

nohup java -cp testJar.jar testClassFileInJar username > java1.out & 
+0

我試了一下。它不工作:( – Arun