Java api进程执行机器命令

时间:2016-10-12 13:31:25

标签: java process

使用java api Process exceute机器命令:

Sub test()
MsgBox (FileFolderExists("C:\Users\Moez\Desktop\Macro_Project\Test1.pptm"))
End Sub

Private Function FileFolderExists(str As String) As Boolean
Dim sCheck As String
sCheck = Dir(str)

If Len(sCheck) > 0 Then
    FileFolderExists = True
Else
    FileFolderExists = False
End If
End Function

这是log,execute命令:bin / ps -ef | grep -w 6005 | grep的 -v grep,但有时结果是空的

执行命令:/ bin / ps -ef | grep -w 6005 | grep -v grep
INFO printExecStdErr,命令:/ bin / ps -ef | grep -w 6005 | grep的 -v grep
INFO执行命令:/ bin / ps -ef | grep -w 6005 | grep -v grep 的结果
执行命令:/ bin / ps -ef | grep -w 6006 | grep -v grep成功

大部分结果是:
执行命令:/ bin / ps -ef | grep -w 26006 | grep -v grep 结果:工作24643 1 0 17:39? 00:00:00 / opt / soft / redis28 / bin / redis-server *:26006

这是怎么回事?我使用了process.waitFor(3000,TimeUnit.MILLISECONDS),但它没用。

0 个答案:

没有答案
相关问题