exec

Explain the bash command “exec > >(tee $LOG_FILE) 2>&1”

牧云@^-^@ 提交于 2020-12-02 08:52:20
问题 My intent was to have all the output of my bash script displayed on the console and logged to a file. Here is my script that works as expected. #!/bin/bash LOG_FILE="test_log.log" touch $LOG_FILE # output to console and to logfile exec > >(tee $LOG_FILE) 2>&1 echo "Starting command ls" ls -al echo "End of script" However I do not understand why it works that way. I expected to have exec >>(tee $LOG_FILE) 2>&1 work but it fails although exec >>$LOG_FILE 2>&1 indeed works. I could not find the

Explain the bash command “exec > >(tee $LOG_FILE) 2>&1”

与世无争的帅哥 提交于 2020-12-02 08:50:37
问题 My intent was to have all the output of my bash script displayed on the console and logged to a file. Here is my script that works as expected. #!/bin/bash LOG_FILE="test_log.log" touch $LOG_FILE # output to console and to logfile exec > >(tee $LOG_FILE) 2>&1 echo "Starting command ls" ls -al echo "End of script" However I do not understand why it works that way. I expected to have exec >>(tee $LOG_FILE) 2>&1 work but it fails although exec >>$LOG_FILE 2>&1 indeed works. I could not find the

Explain the bash command “exec > >(tee $LOG_FILE) 2>&1”

落花浮王杯 提交于 2020-12-02 08:48:12
问题 My intent was to have all the output of my bash script displayed on the console and logged to a file. Here is my script that works as expected. #!/bin/bash LOG_FILE="test_log.log" touch $LOG_FILE # output to console and to logfile exec > >(tee $LOG_FILE) 2>&1 echo "Starting command ls" ls -al echo "End of script" However I do not understand why it works that way. I expected to have exec >>(tee $LOG_FILE) 2>&1 work but it fails although exec >>$LOG_FILE 2>&1 indeed works. I could not find the

Executing command with spaces in one of the parts

不打扰是莪最后的温柔 提交于 2020-11-29 10:34:50
问题 I am running a command through the os/exec package that is called like this: out, err := Exec("ffprobe -i '/media/Name of File.mp3' -show_entries format=duration -v quiet -of csv=p=0", true, true) The function I have written to execute command line calls is: func Exec(command string, showOutput bool, returnOutput bool) (string, error) { log.Println("Running command: " + command) lastQuote := rune(0) f := func(c rune) bool { switch { case c == lastQuote: lastQuote = rune(0) return false case

Composer.phar don't want to run by shell_exec from PHP script. Why?

女生的网名这么多〃 提交于 2020-08-19 12:28:46
问题 Trying to execute it with all possible params, such as -d and full path etc.. No errors. When running another commands, all is ok, when running composer from CMD, all is ok too. Have tried exec, system, shell_exec etc.. What it could be? echo system('php composer.phar install'); 回答1: Try outputting the error stream as well: system('php composer.phar install 2>&1'); It might give you more of a hint as to what is going wrong. 回答2: Try this $path = 'path where, composer.phar and composer.json

Composer.phar don't want to run by shell_exec from PHP script. Why?

三世轮回 提交于 2020-08-19 12:21:51
问题 Trying to execute it with all possible params, such as -d and full path etc.. No errors. When running another commands, all is ok, when running composer from CMD, all is ok too. Have tried exec, system, shell_exec etc.. What it could be? echo system('php composer.phar install'); 回答1: Try outputting the error stream as well: system('php composer.phar install 2>&1'); It might give you more of a hint as to what is going wrong. 回答2: Try this $path = 'path where, composer.phar and composer.json