Add function to execute a shell command and return the output (Issue 8676)