Show EXECUTE_PROCESS output for commands like dir or echo on stdout

前端 未结 1 1995
再見小時候
再見小時候 2021-02-14 03:05

I would like to directly see the output of a command started by the EXECUTE_PROCESS command on stdout while the program is running.

I have the following te

相关标签:
1条回答
  • 2021-02-14 03:21

    Try:

    execute_process(COMMAND cmd /c dir)
    

    instead. 'dir' is a built-in shell command. 'execute_process' expects a *.exe file name as it's first argument after COMMAND. (Or some exe available in the PATH.)

    In fact, if you try to dig in and find out what's wrong with your original execute_process call...

    execute_process(COMMAND dir RESULT_VARIABLE rv)
    message("rv='${rv}'")
    

    ...you'll get this output:

    rv='The system cannot find the file specified'
    

    Which is pretty much what you'd get if you passed "dir" to the WIN32 CreateProcess call.

    0 讨论(0)
提交回复
热议问题