stdout

How to have an in-place string that updates on stdout

白昼怎懂夜的黑 提交于 2019-12-02 14:37:08
I want to output to stdout and have the output "overwrite" the previous output. For example; if I output On 1/10 , I want the next output On 2/10 to overwrite On 1/10 . How can I do this? zzzz stdout is a stream ( io.Writer ). You cannot modify what was already written to it. What can be changed is how that stream's represented in case it is printed to a terminal. Note that there's no good reason to assume this scenario. For example, a user could redirect stdout to a pipe or to a file at will. So the proper approach is to first check: if the stdout is going to a terminal what is that terminal

How can I redirect STDERR to STDOUT, but ignore the original STDOUT? [duplicate]

泄露秘密 提交于 2019-12-02 14:26:58
This question already has an answer here: How to pipe stderr, and not stdout? 12 answers I have a program whose STDERR output I want to inspect and run grep on etc. So I could redirect it to STDOUT and use grep, but the problem is, I do not want the original STDOUT content. So, this one won't do cmd 2>&1 | grep pattern because it will mix the original STDOUT and STDERR. And this one doesn't work since grep doesn't read the STDERR output: cmd 1>/dev/null | grep pattern But also, this one won't work: cmd 1>/dev/null 2>&1 | grep pattern because the output will be completely empty, since

stdin stdout python: how to reuse the same input file twice?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 12:54:43
问题 I am quite new to Python and even newer to stdin stdout method. Nevertheless I need to make my script usable for UNIX commands, in order to make it possible for example to process 2 input files at once with my script. This script works perfectly well with command line arguments: newlist = [] def f1() .... def f2(input_file): vol_id = sys.argv[3] for line in input_file: if ... : line = line.replace('abc','def') line = line.replace('id', 'id'+vol_id) .... newlist.append(line) return newlist def

What is an appropriate way to programmatically exit an application?

好久不见. 提交于 2019-12-02 12:44:22
I am evaluating user inputs as commands for my application. If the user presses Q , or q , and then hits enter, the application quits and execution terminates. Is there a proper context, or best practices on how to do that? I do not have any resources to release, or anything like that. Should I just use System.exit(0); ? Is there a recommended way to do that? As my first approach I do something like this: while (true){ try{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); //Other logic goes here... if (br.readLine().equalsIgnoreCase("Q")){ System.exit(0); } } catch

How do I read the standard output from a child process in VB6?

自作多情 提交于 2019-12-02 12:34:54
When creating a process in VB6 (related to this question:), I'm using the following struct: Private Type STARTUPINFO cb As Long lpReserved As String lpDesktop As String lpTitle As String dwX As Long dwY As Long dwXSize As Long dwYSize As Long dwXCountChars As Long dwYCountChars As Long dwFillAttribute As Long dwFlags As Long wShowWindow As Integer cbReserved2 As Integer lpReserved2 As Long hStdInput As Long hStdOutput As Long hStdError As Long End Type Before I start my process, what needs to happen to STARTUPINFO.hStdOutput in order for my VB6 app to read the output of my hosted process?

Streaming an MP3 on stdout to Jplayer using PHP

主宰稳场 提交于 2019-12-02 10:27:14
问题 I'm initializing jplayer with the following parameters: $jplayer.jPlayer('setMedia',{ mp3: data.audioMP3, oga: data.audioOGA }); Assume that data.autdioMP3 (and it's OGA counterpart) are paths to a php script, for example: 'http://myserver.local/playaudio.php?songID=99&format=mp3' Where I am struggling is with playaudio.php . I would like to read the MP3 file and stream it to jplayer without revealing the path to the audio (this is why I am not initializing jplayer with a path to the audio

Duplicate stdout and stderr from fork process to files

可紊 提交于 2019-12-02 10:02:34
I need to duplicate stdout and stderr of a child proccess to multiple files. I understand that i can use tee() , but I haven't found examples for that. Now, it's only to print all to stdout and stderr. How to do it? pid_t childId = fork(); switch(childId){ case -1: perror("fork() error!\n"); return; case 0: mysignal(SIGTTOU, SIG_DFL); mysignal(SIGTTIN, SIG_DFL); mysignal(SIGCHLD, SIG_DFL); if(!background) tcsetpgrp(cterm, getpid()); setpgid(0, 0); if (isWriter) close(pipefd[0]); if (isReader!=-1) { close(0); dup(oldChannelOut); } if(isWriter){ close(1); dup(pipefd[1]); } //exec, if program is

Batch script: save stdout and have the output in the console too

邮差的信 提交于 2019-12-02 08:27:46
By default the output of commandline applications is presented in console window and I know that using > or >> we can re-wrire/append the stdout to an external file but what if the commandline application doesn't have internal logging facility to save the output. I want the stdout to be both in the console and be saved in an external file. Is such a thing possible? Try something like this: @echo off echo hello > log.txt & type log.txt pause But using this you can only have one command-output in the log-file at once. You could try it with >> but that way you get the outputs of all commands

Duplicate stdout, stderr in QTextEdit widget

南楼画角 提交于 2019-12-02 07:39:11
问题 I've been having difficulty with my PySide program for a few days now. I don't think the problem is incredibly difficult because there are answer out there. Problem I have is none of them seem to work for me. I want to 'listen' to the file objects stdout and stderr and output the contents to QText Edit widget while my PySide program is running. Now, I already realise this question (or something similar) has been asked before on here but like I said, can't get it to work for me for some reason

Duplicate stdout, stderr in QTextEdit widget

不问归期 提交于 2019-12-02 07:17:43
I've been having difficulty with my PySide program for a few days now. I don't think the problem is incredibly difficult because there are answer out there. Problem I have is none of them seem to work for me. I want to 'listen' to the file objects stdout and stderr and output the contents to QText Edit widget while my PySide program is running. Now, I already realise this question (or something similar) has been asked before on here but like I said, can't get it to work for me for some reason and most other solutions out there are based on the one that I can't get working, so a very