PHP Exec command - How to pass input to a series of questions

前端 未结 3 1557
误落风尘
误落风尘 2021-01-12 11:47

I have a program on my linux server that asks the same series of questions each time it executes and then provides several lines of output. My goal is to automate the input

3条回答
  •  礼貌的吻别
    2021-01-12 12:31

    Just add the arguments to the exec line.

    exec("/path/to/programname $arg1 $arg2 $arg3");
    

    ... but don't forget to apply escapeshellarg() on every argument! Otherwise, you're vulnerable to injected malicious code.

提交回复
热议问题