Running Bash commands in Java

后端 未结 7 1299
名媛妹妹
名媛妹妹 2020-11-30 06:03

I have the following class. It allows me to execute commands through java.

public class ExecuteShellCommand {

public String executeCommand(String command) {         


        
7条回答
  •  一生所求
    2020-11-30 06:36

    each command you are running has its own bash shell, so once you cd to that directory and for next command you are opening new bash shell

    try changing your command to

    ls bin
    

提交回复
热议问题