stderr

simplify function call that writes to output stream and returns value

大憨熊 提交于 2020-07-10 07:07:07
问题 This is a follow up question for write to output stream and returning value from shell script function. In shell script, echo can be used to return values from functions. But, if those functions want to print some messages. Then, this can be done by redirecting it to error stream. But when the script is used as a autosys job. then messages from logic functions ends up in error stream file triggering alerts. Is there any way, messages from logic function can be written to output stream and not

write to output stream and returning value from shell script function

眉间皱痕 提交于 2020-07-10 03:11:48
问题 In shell script, echo can be used to return values from functions. But, if those functions want to print some messages. Then, this can be done by redirecting it to error stream. Below is a simplified example :- #this is a function that returns a value, as well as #print some messages function logic(){ echo >&2 "start of logic" echo >&2 "perform logic, to get value" echo "ok" } function smain(){ local result=$(logic) echo "result is >$result<" if [ "$result" == "ok" ];then echo "script

write to output stream and returning value from shell script function

六月ゝ 毕业季﹏ 提交于 2020-07-10 03:11:43
问题 In shell script, echo can be used to return values from functions. But, if those functions want to print some messages. Then, this can be done by redirecting it to error stream. Below is a simplified example :- #this is a function that returns a value, as well as #print some messages function logic(){ echo >&2 "start of logic" echo >&2 "perform logic, to get value" echo "ok" } function smain(){ local result=$(logic) echo "result is >$result<" if [ "$result" == "ok" ];then echo "script

Modifying “… | tee -a out.txt” to stream output live, rather than on completion?

 ̄綄美尐妖づ 提交于 2020-06-15 05:59:08
问题 I would need to output the output of a command on a file. Let's say my command is zip -r zip.zip directory , I would need to append/write (any of these options would be fine) to a file (let's say out.txt ). I got zip zip.zip directory | tee -a out.txt so far, but it doesn't seem to work, it just writes the whole output when the command is over... How can I achieve this? Thanks ;) 回答1: Background (ie. Why?) Redirections are immediate -- when you run somecommand | tee -a out.txt , somecommand

Stop git from writing non-errors to stderr

爱⌒轻易说出口 提交于 2020-06-08 12:51:23
问题 I have a script that I am using to automatically sync various remote git repositories. One thing I am trying to do with my scripts is to capture the output of stderr from every command and write all those errors into a text file that is then emailed to me after the script has finished. This will alert me to any problems that I need to fix. I am having a problem with the following two lines though: { git fetch --prune-tags github-fetch master git push github master } 2> '/tmp/stderr-contents

Stop git from writing non-errors to stderr

六月ゝ 毕业季﹏ 提交于 2020-06-08 12:50:31
问题 I have a script that I am using to automatically sync various remote git repositories. One thing I am trying to do with my scripts is to capture the output of stderr from every command and write all those errors into a text file that is then emailed to me after the script has finished. This will alert me to any problems that I need to fix. I am having a problem with the following two lines though: { git fetch --prune-tags github-fetch master git push github master } 2> '/tmp/stderr-contents

Gradle: How to get output from test STDERR/STDOUT into console?

我的梦境 提交于 2020-05-07 10:43:11
问题 (Gradle 3.2.1) I run some java tests, which logs output in Stderr/Stdout. I can see that output, if I start gradle test --info but in that case, much of unwanted output from 3-rd party libraries is there too. Documentation suggests using logging.caputureStandardError / logging.caputureStandardError (loglevel) , but it doesn't seem to have any effect. tasks.withType(Test) { logging.captureStandardOutput LogLevel.QUIET logging.captureStandardError LogLevel.QUIET } Then if running gradle test ,

Gradle: How to get output from test STDERR/STDOUT into console?

做~自己de王妃 提交于 2020-05-07 10:43:06
问题 (Gradle 3.2.1) I run some java tests, which logs output in Stderr/Stdout. I can see that output, if I start gradle test --info but in that case, much of unwanted output from 3-rd party libraries is there too. Documentation suggests using logging.caputureStandardError / logging.caputureStandardError (loglevel) , but it doesn't seem to have any effect. tasks.withType(Test) { logging.captureStandardOutput LogLevel.QUIET logging.captureStandardError LogLevel.QUIET } Then if running gradle test ,

Log stdout + stderr and stderr simultaneously in R

一个人想着一个人 提交于 2020-04-16 05:49:39
问题 I want to have all stdout + stderr in one log file and simultaneously just stderr in another. How can I achieve this in R? Messages must keep the chronological order of all messages in both logs, for example say I have this code: options(warn = 1) cat("1st stdout\n") warning("2nd stderr") cat("3rd stdout\n") warning("4th stderr") How to make it redirect to both logs in the desired way? My thought that it could be simple if it was possible to merge and split the R connections, see the question

Log stdout + stderr and stderr simultaneously in R

半城伤御伤魂 提交于 2020-04-16 05:49:33
问题 I want to have all stdout + stderr in one log file and simultaneously just stderr in another. How can I achieve this in R? Messages must keep the chronological order of all messages in both logs, for example say I have this code: options(warn = 1) cat("1st stdout\n") warning("2nd stderr") cat("3rd stdout\n") warning("4th stderr") How to make it redirect to both logs in the desired way? My thought that it could be simple if it was possible to merge and split the R connections, see the question