Menu
  • HOME
  • TAGS

Is it possible to change newline constant for $stderr in Ruby?

ruby,newline,stderr

As @Stefan wrote in the comment, probably you should use an HTML <pre> tag instead, or CSS white-space: pre directive on a non-pre element. Anyway: $stderr.print: def $stderr.print(*args) super *args.map { |v| v.to_s.gsub("\n", "<br>") } end $stderr.print "ciao\n" #=> nil ciao<br> $stderr.puts: def $stderr.puts(*args) print *args.map { |v| v.to_s +...

Redirect execution errors to file c++

c++,linux,bash,stdout,stderr

I found something that worked in my terminal, here: http://bytes.com/topic/c/answers/822874-runtime-error-stderr-gcc-ubuntu-bash In summary, a participant explained: In this particular case, the reason that the string "Floating point exception" is not >redirected is that it is not produced by the process that runs ./{file} or anything that it invokes. Instead,it is being...

IO Redirection in Linux Bash shell scripts not recreating moved/deleted file?

linux,bash,stdout,stderr,io-redirection

Yes, it is. Unless you first program reopen the files, it will keep writing to the old file, even if you can't access it anymore. In fact, the space used by that removed file will only be available after every process closes it. If reopening it is not possible (ie....

What does >>& mean in a tcsh script and how does it translate to bash?

bash,stdout,stderr,tcsh

It appends both stdout and stderr to the file, so it's equivalent to: wget --output-document=/dev/null "http://somewebsite.org" >> /root/wget.log 2>&1 ...

Why stdout for error messages [closed]

c,stdout,stderr,error-reporting

It's lazyness. stderr was created to print error messages, so you can redirect the output of a program without having mixed error messages. Also, I think stderr is unbuffered by default, so if your program crash, all the error messages up to the point where it crashed are printed (this...

Controlling stderr and stdout output in WildFly

logging,stderr,wildfly-8

OK, with some googling and hacking I got what I want: /subsystem=logging/console-handler=JUST-PRINT:add(formatter="%s%E%n") /subsystem=logging/logger=stderr:add(use-parent-handlers="false", handlers=[JUST-PRINT]) /subsystem=logging/logger=stdout:add(use-parent-handlers="false", handlers=[JUST-PRINT]) ...

PHP exec() nohup with redirect

php,exec,stdout,stderr,nohup

Got it working. Python does its own output buffering which kept it from writing to the file. Running it with the -u option disables this. Final code looks like this: exec("nohup python -u main.py -i 1 > /var/scripts/logs/1_out.log 2>&1 </dev/null &"); Thanks....

TypeError for pickle of array of custom objects in Python

python,pickle,kivy,stderr

Indeed, the Kivy EventDispatcher object is at fault here; the object.__reduce_ex__ method searches for the first baseclass that is not a custom class (it does not have the Py_TPFLAGS_HEAPTYPE flag set), to call __init__ on that class. This fails for that base class, as it's __init__ method doesn't support passing...

How to capture stderr to a variable if there is an error executing the script?

bash,amazon-web-services,stderr,aws-cli

myCmd=("aws --profile myProfile --region eu-west-1 ec2 authorize-security-group-ingress --group-id sg-999aa999 --protocol tcp --port 80 --cidr 0.0.0.0/0 ") if "${myCmd[@]}" > myJson.file 2> error.file; then echo ok else err="$(cat error.file)" # do domething with $err fi ...

Why does my program not check the number of arguments correctly?

c,command-line-arguments,binary-search-tree,stderr

argc will always be at least 1 because argv[0] contains the path to the executable. Therefore you should be checking if ( argc != 3 ) since you are passing 2 arguments from the command line. When you execute ./a.out main.c input.txt, argv[1] will be main.c and argv[2] will be...

PowerShell Redirect all output to a file

powershell,stderr

I think I've found it: Write-Error 'bla' 2>&1 | Out-File -LiteralPath '\\SERVER\s$\Test\test[0].log' -Append ...

Monitor STDERR of all processes running on my linux machine

linux,monitoring,stderr,ptrace

Maybe this question would get more answers on SU. The only thing I could think of would be to monitor the files and devices already opened as STDERR. Of course, this would not work if STDERR is redirected to /dev/null. You can get all the file descriptors for STDERR with:...

Trouble printing text live with Python subprocess.call

python,subprocess,stdout,stderr

Try: def run(command): proc = subprocess.Popen(command, stdout=subprocess.PIPE) for lineno, line in enumerate(proc.stdout): try: print(line.decode('utf-8').replace('\n', '')) except UnicodeDecodeError: print('error(%d): cannot decode %s' % (lineno, line)) The try...except logic is for python 3 (maybe 3.2/3.3, I'm not sure), as there line is a byte array not a string. For earlier versions of...

Redirecting C++ generated cerr and cout to the same file in Ubuntu

c++,bash,cout,stderr,redirecting

In bash, you should do the following: ./a.out source > target 2>&1 to merge stderr into stdout. The command you gave is meant for csh. And if you want to merge stderr into stdout, you will do ./a.out source 2> target 1>&2 ...

Bash: how do I pipe stdout and stderr of one process to two different processes?

bash,pipe,stdout,stderr

Without fancy games something like this should work: { myProcess1 | myProcess2 > results-out.txt; } 2>&1 | myprocess3 > results-err.txt With fancy games (which do not work in /bin/sh, etc.) you could do something like this: myProcess1 2> >(myprocess3 > results-err.txt) | myProcess2 > results-out.txt ...

Python subprocess with /usr/bin/time: how to capture timing info but ignore all other output?

python,python-2.7,time,stdout,stderr

%e /usr/bin/time format is: Elapsed real (wall clock) time used by the process, in seconds. To run a subprocess with suppressed stdout/stderr and get the elapsed time: #!/usr/bin/env python import os import time from subprocess import check_call, STDOUT DEVNULL = open(os.devnull, 'wb', 0) start = time.time() check_call(['sleep', '1'], stdout=DEVNULL, stderr=STDOUT)...

Unable to process python subprocess stderr on windows

python,windows,subprocess,stderr

As discussed in chat, the numbers are coming from stderr. By printing the ascii-indexes of each character in line, we discovered that the final line returned by readline() is \t75,881,728 \r175,882,240 \r\n. It looks like the \r embedded in the middle of this string (which DD outputs) is confusing your...

cron job not running with adding “2>&1”

bash,cron,crontab,stderr

The default behaviour of cron is to send stderr via email to the user running the cronjob. From man cron: When executing commands, any output is mailed to the owner of the crontab (or to the user specified in the MAILTO environment variable in the crontab, if such exists). To...

How to make all stderr also go to stdout in Ruby CGI script

ruby,cgi,stdout,stderr

To redirect stderr to stdout from inside a Ruby script you can use the IO#reopen method: # script.rb $stderr.reopen($stdout) fail 'error' # Messages from execeptions are usually printed on stderr If you run the script in the shell, redirecting stderr to /dev/null, you can see that the exception message is...

Where does C++ stderr output go in OSX?

c++,xcode,osx,objective-c++,stderr

You can use the lsof command to figure out where a particular file descriptor has been redirected: lsof -p <your pid> -d 0,1,2 When a background process is launched usually the child proccess is attached to the same standard streams as the parent process. For normal Cocoa applications by default...

linux find command — need to filter “no such file or directory” messages without redirecting stderr

linux,find,stderr,chown

Use process substitution: find / -user fred -exec chown -c joe {} \; \ 2> >(grep -v 'no such file or directory' >&2) 2> redirects stderr; >(...) reads the redirected stderr, grep -v removes the unwanted lines, and >&2 returns the remaining lines back to stderr...

Where does stderr go on G-WAN?

stderr,g-wan

Where does stderr go on G-WAN? If I remember well, stdin, strerr and stdout are closed in the daemon mode because they are unreachable anyway as G-WAN was dettached from its parent terminal. But in the 'interactive' mode, where G-WAN still shows console output like compilation errors and 'gracefull'...

Ant places stacktraces in standard output

java,logging,ant,stderr

You can implement the same code as in Echo task import java.io.IOException; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.util.ResourceUtils; import org.apache.tools.ant.types.resources.LogOutputResource; import org.apache.tools.ant.types.resources.StringResource; public class MyLogTask extends Task { private String msg; public void execute() throws BuildException { try { ResourceUtils.copyResource(new StringResource(msg), new...

How to conceal a segmentation fault in a bash script

osx,bash,segmentation-fault,posix,stderr

From the Bad Idea Department: program options >file 2>/dev/null | cat It seems that bash won’t complain about segmentation faults in programs whose output is piped elsewhere. So just pipe your output anywhere. cat is a good choice, since it just echos the text it was sent. Or pipe to...

On a Linux system, how would I redirect stdout to stderr?

linux,stdout,stderr

To redirect the stdout to stderr, use your command as follows :- $ command-name 1>&2 where command-name is the command you're going to feed, 1 represents stdout and 2 represents stderr ....

C++ equivalent of fprintf with error

c++,c,printf,stderr

All [with a few exceptions where C and C++ collide with regards to standard] valid C code is technically also valid (but not necesarrily "good") C++ code. I personally would write this code as : if (result == 0) { std::cerr << "Error type " << error_type << std:: endl;...

Nginx log to stderr

logging,nginx,stderr,systemd

According to the nginx documentation, the error_log directive supports stderr as its argument. The following configuration should therefore log error messages to stderr: http { error_log stderr; ... } Unfortunately, access_log doesn't support stdout as its argument. However, it should be possible to set it to syslog (documentation) and get...

Send stderr/stdout messages to function and trap exit signal

bash,shell,unix,stdout,stderr

You have to use set -o pipefail See this related StackOverflow Question. Minimal example: #!/bin/bash trap handler ERR handler() { echo trapped ; } echo 1 false | : echo 2 set -o pipefail false | : Output: $ bash test.sh 1 2 trapped ...

redirect stderr stdout both on console and log file

linux,bash,stdout,stderr

use tee, which will redirect the stdin to both a file and stdout: ./BT_API connect $2 | bluetoothctl 2>&1 | tee /tmp/BT_TMP ...

stdout and stderr redirection in child process

bash,unix,process,stdout,stderr

Creating a child process on UNIX/Linux uses a procedure generically known as a fork. What this does is to copy almost the entire process address space of the current process (program code, data, almost everything) to the child. The Process IDentifier (PID) is different in the child, but almost everything...