stdout

How to process stdin to stdout in php?

只愿长相守 提交于 2019-12-04 10:10:33
I'm trying to write a simple php script to take in data from stdin , process it, then write it to stdout . I know that PHP is probably not the best language for this kind of thing, but there is existing functionality that I need. I've tried <?php $file = file_get_contents("php://stdin", "r"); echo $file; ?> but it doesn't work. I'm invoking it like this: echo -e "\ndata\n" | php script.php | cat . and get no error messages. The script I'm trying to build will actually be part of a larger pipeline. Any clues as to why this is not working? PS: I'm not very experienced with PHP. If you are piping

Can anyone give me a quick tutorial in stdin and stdout in Python 3? [closed]

为君一笑 提交于 2019-12-04 08:44:51
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I know this sounds like something I can google, but the truth is that I don't find or do not understand what the very few Python 3

Using tee to get realtime print statements from python [duplicate]

感情迁移 提交于 2019-12-04 08:24:22
问题 This question already has answers here : Disable output buffering (16 answers) Closed 5 years ago . This question was migrated from Unix & Linux Stack Exchange because it can be answered on Stack Overflow. Migrated 5 years ago . I have a python script that looks something like this: for item in collection: print "what up" #do complicated stuff that takes a long time. In bash, I run this script by doing the following: $ python my.py | tee my_file.txt However, all I see in bash is a blank line

Read from stdin write to stdout in C

戏子无情 提交于 2019-12-04 08:23:10
问题 I am trying to write a cat clone to exercise C, I have this code: #include <stdio.h> #define BLOCK_SIZE 512 int main(int argc, const char *argv[]) { if (argc == 1) { // copy stdin to stdout char buffer[BLOCK_SIZE]; while(!feof(stdin)) { size_t bytes = fread(buffer, BLOCK_SIZE, sizeof(char),stdin); fwrite(buffer, bytes, sizeof(char),stdout); } } else printf("Not implemented.\n"); return 0; } I tried echo "1..2..3.." | ./cat and ./cat < garbage.txt but I don't see any output on terminal. What I

Simultaneous pipe to grep and redirect to stdout

ε祈祈猫儿з 提交于 2019-12-04 08:01:38
In Linux bash, I am trying to run a command and grep for an argument: command | grep However, I need to redirect the result of the commad to the stdout and simultaneously pipe it to grep (I need to see both the grep result and the command result in stdout). I googled a bit and tried some variations, such as: command | tee /dev/tty | grep But, no luck. I don't want to use sth like command command | grep as it is ugly :) Thanks, Try command | tee >(grep whatever) Note that there's no space between these two symbols: >( . 来源: https://stackoverflow.com/questions/23066559/simultaneous-pipe-to-grep

Reassigning global $stdout to console - ruby

你离开我真会死。 提交于 2019-12-04 07:50:47
I am trying to set $stdout to write to a file temporarily and then back to a file. test.rb : old_stdout = $stdout $stdout.reopen("mytestfile.out",'w+') puts "this goes in mytestfile" $stdout= old_stdout puts "this should be on the console" $stdout.reopen("mytestfile1.out",'w+') puts "this goes in mytestfile1:" $stdout = old_stdout puts "this should be back on the console" Here is the output. ruby test.rb => no output on the console cat mytestfile.out this goes in mytestfile this should be on the console cat mytestfile1.out this goes in mytestfile1: this should be back on the console I am not

Communicate with subprocess without waiting for the subprocess to terminate on windows

老子叫甜甜 提交于 2019-12-04 07:03:52
I have a simple echoprocess.py: import sys while True: data = sys.stdin.read() sys.stdout.write("Here is the data: " + str(data)) And a parentprocess.py from subprocess import Popen, PIPE proc = Popen(["C:/python27/python.exe", "echoprocess.py"], stdin = PIPE, sdtout = PIPE) proc.stdin.write("hello") print proc.stdout.read() This just hangs until echoprocess.py is terminated. I want to communicate with this subprocess multiple times without having to restart it again. Is this kind of interprocess communication possible with the Python subprocess module on Windows? The main problem is with the

Prevent mixing of console output and written text

随声附和 提交于 2019-12-04 06:39:54
问题 I have a C++ console application that prints some output constantly while it also accepts commands (using std::cin ) from the user - output and input happen in separate threads. If I write a text while some output appears the written text is mixed with application output. How can I prevent this behaviour? To solve this problem, I need to display the program one line above the line where the text is typed. I'd inspire myself in Minecraft Bukkit server's solution - however I need the same for C

How to keep the unit test output in Jenkins

淺唱寂寞╮ 提交于 2019-12-04 06:00:00
We have managed to have Jenkins correctly parse our XML output from our tests and also included the error information, when there is one. So that it is possible to see, directly in the TestCase in Jenkins the error that occurred. What we would like to do is to have Jenkins keep a log output, which is basically the console output, associated with each case. This would enable anyone to see the actual console output of each test case, failed or not. I haven't seen a way to do this. * EDIT * Clarification - I want to be able to see the actual test output directly in the Jenkins interface, the same