Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • /script1.pl < input_string reads the file named input_string, it does not feed the literal string input_string as input. Commented Dec 26, 2013 at 18:38
  • Ah I see. I would like to feed an actual string to my python implementation though. I will iterate through strings using a generator, and I want to pass the generated strings through the pipe on the fly. Commented Dec 26, 2013 at 18:42
  • your shell command is not compatible with "keep the stream open". What do you want to put into output_string (the first byte, the first line, the first n bytes, the first bytes that arrive in 10 seconds)? btw, output_string = process.communicate(input_string)[0] reproduces your shell command (if we use strings instead of files). Commented Dec 26, 2013 at 19:07
  • My apologies for the confusion. My shell command reads from a large file with a lot of lines, and writes to another file. I can't open and read the whole file in python. Rather, I have to read line by line, and pass each line into the pipe stream. I would like to keep the pipe stream open until all lines are passed through it. Commented Dec 26, 2013 at 19:23
  • Edited my question to clarify the problem. Thanks. Commented Dec 26, 2013 at 19:25