How to invoke external command from within Kotlin code?

后端 未结 7 1421
花落未央
花落未央 2020-11-29 22:08

I want to invoke an external command from Kotlin code. In C/Perl, I would use system() function. In Python, I would use the subprocess module. In Go, I would us

7条回答
  •  粉色の甜心
    2020-11-29 22:40

    If you're running on the JVM you can just use Java Runtime exec method. e.g.

    Runtime.getRuntime().exec("mycommand.sh")
    

    You will need to have security permission to execute commands.

提交回复
热议问题