help on "call a unix command in java"# Java - 爪哇娇娃
b*y
1 楼
I wanna test if there is a duplicate instance running.
So, I am trying to call the following unix commands,
ps acx > ./ps_Client.txt
and
grep -c Client ./ps_Client.txt > ./grep_Client.txt
but when I try to open the file grep_Client.txt, I got the
FileNotFoundException, there is no such file at all.
The follows are my code,
String SysCommand = "ps acx > ./ps_Client.txt";
Process p = Runtime.getRuntime().exec(SysCommand);
SysCommand = "grep -c Client ./ps_Client.txt > ./grep_Client.txt";
Process p
So, I am trying to call the following unix commands,
ps acx > ./ps_Client.txt
and
grep -c Client ./ps_Client.txt > ./grep_Client.txt
but when I try to open the file grep_Client.txt, I got the
FileNotFoundException, there is no such file at all.
The follows are my code,
String SysCommand = "ps acx > ./ps_Client.txt";
Process p = Runtime.getRuntime().exec(SysCommand);
SysCommand = "grep -c Client ./ps_Client.txt > ./grep_Client.txt";
Process p