io-redirection

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

powershell cmdlet how to pipe information or error to write-eventlog

本秂侑毒 提交于 2020-08-25 09:01:42
问题 i'm trying to output to eventlog to the correct Entry Type (Information,Warning,Error) based on the stream that is coming out of my cmdlet, something like this: function myfunction { Param( [switch]$stream1, [switch]$stream2 ) if ($stream1) {write-output 'stream 1 msg'} if ($stream2) {write-error 'stream 2 msg'} } $eventlogparams = @{'logname'='application';'source'='myapp';'eventid'='1'} myfunction -stream1 -stream2 ` 1> write-eventlog @eventlogparams -entrytype information -message $_ ` 2>

powershell cmdlet how to pipe information or error to write-eventlog

给你一囗甜甜゛ 提交于 2020-08-25 09:01:42
问题 i'm trying to output to eventlog to the correct Entry Type (Information,Warning,Error) based on the stream that is coming out of my cmdlet, something like this: function myfunction { Param( [switch]$stream1, [switch]$stream2 ) if ($stream1) {write-output 'stream 1 msg'} if ($stream2) {write-error 'stream 2 msg'} } $eventlogparams = @{'logname'='application';'source'='myapp';'eventid'='1'} myfunction -stream1 -stream2 ` 1> write-eventlog @eventlogparams -entrytype information -message $_ ` 2>

Redirect STDOUT to new window, STDERR to same new window and also a log file

耗尽温柔 提交于 2020-08-20 08:12:32
问题 I have this long process in a bash script (one of many) and so I'm experimenting with sending all output to a separate window to monitor, with any errors logged to errorlog.txt . For example: rsync -vahPz foo@bar:/bigfolder/ ./ >> /dev/pts/4 2>> errorlog.txt Trouble is that above doesn't display any errors on the separate window. Is there a way to redirect errors to both my separate window at /dev/pts/4 and errorlog.txt , while still redirecting normal output to /dev/pts/4 too? Something like

Redirect STDOUT to new window, STDERR to same new window and also a log file

牧云@^-^@ 提交于 2020-08-20 08:12:07
问题 I have this long process in a bash script (one of many) and so I'm experimenting with sending all output to a separate window to monitor, with any errors logged to errorlog.txt . For example: rsync -vahPz foo@bar:/bigfolder/ ./ >> /dev/pts/4 2>> errorlog.txt Trouble is that above doesn't display any errors on the separate window. Is there a way to redirect errors to both my separate window at /dev/pts/4 and errorlog.txt , while still redirecting normal output to /dev/pts/4 too? Something like

redirecting result of running assembly code in linux to text file [duplicate]

自作多情 提交于 2020-06-27 18:30:47
问题 This question already has answers here : Using printf in assembly leads to an empty ouput (2 answers) Can ptrace tell if an x86 system call used the 64-bit or 32-bit ABI? (1 answer) What happens if you use the 32-bit int 0x80 Linux ABI in 64-bit code? (1 answer) Closed 7 days ago . I'm trying to write a Python script to test the output of some various code I've written in assembly against an expected output. However I am having difficulty redirecting the output into a file. I have written the

Redirect copy of stdin to file from within bash script itself

爱⌒轻易说出口 提交于 2020-06-27 17:11:42
问题 In reference to https://stackoverflow.com/a/11886837/1996022 (also shamelessly stole the title) where the question is how to capture the script's output I would like to know how I can additionally capture the scripts input. Mainly so scripts that also have user input produce complete logs. I tried things like exec 3< <(tee -ia foo.log <&3) exec <&3 <(tee -ia foo.log <&3) But nothing seems to work. I'm probably just missing something. 回答1: Maybe it'd be easier to use the script command? You

Powershell Script output to variable - capture Write-Host output

狂风中的少年 提交于 2020-05-15 10:04:07
问题 Using this script: https://github.com/byterogues/powershell-bittrex-api which I call from another script. e.g. $order = .\bittrex-api.ps1 -action buylimit -market BTC-TX -quantity 1 -rate 0.00011300 bittrex-api.ps1 catches an error and shows this on screen BITTREX ERROR: API Query returned an error. Error Message: MIN_TRADE_REQUIREMENT_NOT_MET How can I capture the output from bittrex-api.ps1 into a variable so I can use this variable in my base script? 回答1: You can't. The script uses Write

Powershell Script output to variable - capture Write-Host output

心已入冬 提交于 2020-05-15 10:04:01
问题 Using this script: https://github.com/byterogues/powershell-bittrex-api which I call from another script. e.g. $order = .\bittrex-api.ps1 -action buylimit -market BTC-TX -quantity 1 -rate 0.00011300 bittrex-api.ps1 catches an error and shows this on screen BITTREX ERROR: API Query returned an error. Error Message: MIN_TRADE_REQUIREMENT_NOT_MET How can I capture the output from bittrex-api.ps1 into a variable so I can use this variable in my base script? 回答1: You can't. The script uses Write