stdin

Read STDIN (SYSIN) in COBOL

别说谁变了你拦得住时间么 提交于 2019-12-10 12:50:02
问题 I want to read the lines out of STDIN (aka SYSIN) in COBOL. For now I just want to print them out so that I know I've got them. From everything I'm reading it looks like this should work: IDENTIFICATION DIVISION. PROGRAM-ID. APP. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT SYSIN ASSIGN TO DA-S-SYSIN ORGANIZATION LINE SEQUENTIAL. DATA DIVISION. FILE SECTION. FD SYSIN. 01 ln PIC X(255). 88 EOF VALUE HIGH-VALUES. WORKING-STORAGE SECTION. PROCEDURE DIVISION. OPEN INPUT SYSIN

Data corruption Piping between C++ and Python

故事扮演 提交于 2019-12-10 12:44:12
问题 I am writing some code that takes binary data from Python, Pipes it to C++, does some processing on the data, (in this case calculating a mutual information metric) and then pipes the results back to python. While testing I have found that everything works fine if the data I send is a set of 2 arrays with dimensions less than 1500 X 1500, but if I send 2 arrays that are 2K X 2K I get back a lot of corrupted nonsense. I currently believe the algorithmic portion of the code is fine because it

C - Replacing words

与世无争的帅哥 提交于 2019-12-10 12:35:02
问题 My goal here is to read text from a file redirected from stdin, then replace certain argv passed words with the word "Replaced". For example, if I run: $ ./a.exe line < input.txt where input.txt is "Test line one", at the end I should print "Test Replaced one." I'm not quite sure where my code is going wrong, sometimes I get segmentation fault, and I'm also not sure how I would go about printing the newOut string, or if I even need one. As a side note, if I was reading using fgets, what if

Python3 : Using input() how to Read Multiple Lines from pipe (stdin)?

风格不统一 提交于 2019-12-10 11:38:09
问题 im just curious while learning python3 and didn't found any good explanation on the web, neither here to my question. reading about input() it says "reads from stdin" so i thought i might experiment and try to use it to read from pipe. and so it does! but only ONE LINE (till EOL). So the next question that came up was how to read multiple lines from pipe (stdin) using input() ? i found sys.stdin and used sys.stdin.isatty() to determine if stdin is bound to a tty or not, assuming that if not

Difference between os.close(0) & sys.stdin.close()

我怕爱的太早我们不能终老 提交于 2019-12-10 10:33:09
问题 I'm working on some Python code which is a CGI script called from Apache. The first thing the code does is (I believe) attempt to close stdin/stdout/stderr with the following: for fd in [0, 1, 2]: try: os.close(fd) except Exception: pass Normally this works, however if they're not open, I get a "python.exe has stopped working", "A problem caused the program to stop working correctly" error message (Win32 exception). Couple of questions: What's the difference between closing via os.close

python non-blocking non-messing-my-tty key press detection

不羁岁月 提交于 2019-12-10 10:12:34
问题 I have a loop that does some work and prints a lot of info to stdout. Over and over again (it's a loop...) What I'd like to do is to detect when / if user presses a key (it can be an arrow, enter, or a letter), and do some work when that happens. This should have been a very simple subsubtask, but I've spent last four hours trying different approaches and getting pretty much nowhere. This needs only work in Linux. Best I could get is something like this below. But that works partially,

Should I set stdout and stdin to be unbuffered in C?

只谈情不闲聊 提交于 2019-12-10 08:57:24
问题 Because of stdin and stdout buffering sometimes printf , scanf and getchar are not executed. I usually flush output buffer using fflush(stdout) but code can become very unreadable because of that. If I set stdin and stdout unbuffered using setbuf(stdin, NULL) and setbuf(stdout, NULL) will I make my program perform better or worse? 回答1: Making stdin or stdout completely unbuffered can make your program perform worse if it handles large quantities of input / output from and to files. Most I/O

C# bi-directional IPC over stdin and stdout

巧了我就是萌 提交于 2019-12-10 04:13:41
问题 How can I connect two C# processes so they can communicate with each other over stdin and stdout? Like this: Process A --> stdout A --> stdin B ---> Process B Process A <-- stdin A <-- stdout B <--- Process B 回答1: using System; using System.Diagnostics; class Program { static void Main(string[] args) { string name; if (args.Length > 0 && args[0] == "slave") { name = "slave"; } else { name = "master"; var info = new ProcessStartInfo(); info.FileName = "BidirConsole.exe"; info.Arguments =

Bash: replacing a substring in pipe stdin

假装没事ソ 提交于 2019-12-10 03:52:27
问题 I try to replace a certain substring from the stdin with a new substring. I have to get the stdin from the pipe, after reading several files by cat . Then I want to push the changed string forward to the pipe. Here is what I try to do: cat file1 file2 | echo ${#(cat)/@path_to_file/'path//to//file'} | ... | ... | ... | ... I try to replace the substring @path_to_file with the replacement substring 'path/to/file' (the surrounding quotes are part of the replacement substring). However bash gives

Golang: Child Processes become Zombies

江枫思渺然 提交于 2019-12-10 02:56:23
问题 I have an application in Go that reroutes the STDIN and STDOUT of binaries and then runs them. In a nutshell I'm doing: - create command object with the binary path (lets call the object command A) - create command object with the binary path (calling it command B) - set the stdout of command B to the stdin of Command A - start command A - start command B I noticed whenever the process for command B exits while command A is running, it becomes a zombie process in the process table. Here's an