yrHeTateJlb
yrHeTateJlb

Reputation: 486

Is it possible to see live output of command runned by execute_process?

I'm running some time consuming bash script:

execute_process(
    COMMAND "bash" "slow_script.sh"
    WORKING_DIRECTORY ${INSTALL_SCRIPT_DIR}
    ERROR_VARIABLE ERROR_MESSAGE
    RESULT_VARIABLE ERROR_CODE)

and I want to see progress. I tried to show xterm window:

execute_process(
    COMMAND "xterm" "-e" "slow_script.sh"
    WORKING_DIRECTORY ${INSTALL_SCRIPT_DIR}
    ERROR_VARIABLE ERROR_MESSAGE
    RESULT_VARIABLE ERROR_CODE)

It works, but seems ugly.

Is it possible to show script output in CMake output while script is executing?

Upvotes: 1

Views: 932

Answers (1)

Florian
Florian

Reputation: 42922

Probably you could use some of the standard /dev devices as OUTPUT_FILE.

The following CMake example worked with a quick test on my Ubuntu machine:

cmake_minimum_required(VERSION 2.4)

project(TestExecuteProcessToStdOut NONE)

execute_process(
    COMMAND "${CMAKE_COMMAND}" -E echo "Test"
    ERROR_VARIABLE ERROR_MESSAGE
    RESULT_VARIABLE ERROR_CODE
    OUTPUT_FILE "/proc/self/fd/0"
)

References

Upvotes: 2

Related Questions