io-redirection

Nested while read loops with fd

混江龙づ霸主 提交于 2021-02-19 04:04:13
问题 I'm trying to read from two different inputs in nested loops without success. I've followed the best answer on this question and also took a look at the file descriptors page of the Advanced Bash-Scripting Guide . Sample script I made to test my problem. #!/bin/bash while read line <&3 ; do echo $line while read _line <&4 ; do echo $_line done 4< "sample-2.txt" done 3< "sample-1.txt" Content of sample-1.txt Foo Foo Content of sample-2.txt Bar Bar Expected output Foo Bar Bar Foo Bar Bar The

How to detect when subprocess asks for input in Windows

南笙酒味 提交于 2021-02-18 10:35:28
问题 I have a subprocess that either quits with a returncode, or asks something and waits for user input. I would like to detect when the process asks the question and quit immediately. The fact that the process asks the question or not is enough for me to decide the state of the system. The problem is that I cannot read the question because the child process probably does not flush standard output. So I cannot rely on parsing subprocess.Popen().stdout : when trying to read it, well, it blocks

Why doesn't command redirection operator work in PyCharm?

不问归期 提交于 2021-02-17 05:46:21
问题 I want to run a python script in PyCharm and redirect the stdin out put to a file. Therefore, I opened Run/Debug configurations and typed: >> output.txt in script parameters field. When I run the script, I get the error: error: unrecognized arguments: >> output.txt Do you know how to use redirection operator in PyCharm environment? 回答1: It is available in Run -->EditConfigurations. On the right side you will have Logs tab which says Save console output to file. You may use that option. 来源:

Creating a virtual parallel for Windows 7 using C++

只谈情不闲聊 提交于 2021-02-10 20:16:05
问题 I am developing an application which would redirect i/o from parallel port of, say, device A to the parallel port of device B . The two devices are connected on ethernet (LAN, WAN, internet, etc.). Device A has a physical parallel port attached to it but device B is a machine with no parallel port on it. This is what makes me emulate a parallel port on device B such that windows thinks that it has a parallel port and works in the very manner with it as it works with parallel ports on hardware

UnicodeEncodeError in python3 when redirection is used

ⅰ亾dé卋堺 提交于 2021-02-10 20:14:13
问题 What I want to do: extract text information from a pdf file and redirect that to a txt file. What I did: pip install pdfminor pdf2txt.py file.pdf > output.txt What I got: UnicodeEncodeError: 'gbk' codec can't encode character '\u2022' in position 0: illegal multibyte sequence My observation: \u2022 is bullet point, • . pdf2txt.py works well without redirection: the bullet point character is written to stdout without any error. My question: Why does redirection cause a python error? As far as

UnicodeEncodeError in python3 when redirection is used

喜你入骨 提交于 2021-02-10 20:11:18
问题 What I want to do: extract text information from a pdf file and redirect that to a txt file. What I did: pip install pdfminor pdf2txt.py file.pdf > output.txt What I got: UnicodeEncodeError: 'gbk' codec can't encode character '\u2022' in position 0: illegal multibyte sequence My observation: \u2022 is bullet point, • . pdf2txt.py works well without redirection: the bullet point character is written to stdout without any error. My question: Why does redirection cause a python error? As far as

Curious tput behavior, with stderr redirection

ε祈祈猫儿з 提交于 2021-02-08 13:50:59
问题 I'm trying to use tput in a Bash script, and doing my best to avoid random error spew. To that end, I wrote the following line: COLS="$(tput cols 2> /dev/null)" To my surprise, when I run this, COLS is consistently set to 80 , no matter what the width of my terminal window happens to be. (For the sake of demonstration, my terminal happens to be 115 columns wide.) To figure out what was going on, I tried a few things on the command-line: $ tput cols 115 $ tput cols | cat 115 $ echo "$(tput

“SFC” output redirection formatting issue - Powershell / Batch

大憨熊 提交于 2021-02-08 08:35:23
问题 I'm working on a powershell script in which several commands output are shown in the window and appended to a file or a variable. It worked correctly until I used the sfc command. When piped or redirected, the output is "broken": > sfc /? Vérificateur de ressources Microsoft (R) Windows (R) version 6.0[...] > sfc /? | Tee-Object -Variable content V Ú r i f i c a t e u r d e r e s s o u r c e s M i c r o s o f t ( R ) W i n d o w s ( R ) v e r s i o á 6 . 0[...] Are there other commands like

Whats the difference between redirections “1>/dev/null 2>&1” and “ 2>&1 1>/dev/null”?

自作多情 提交于 2021-02-04 21:37:16
问题 Whats the difference between redirections 1>/dev/null 2>&1 and 2>&1 1>/dev/null It seems 1st one displays output to stdout but not the second one. Can somebody explain ! Thanks 回答1: Expanding on Lokendra26's answer a bit: /dev/null is a special file on your system, a device for discarding anything written to it. It's common to send output there if you don't want to see it. "File" in this case, and unix terminology in general, can be both a normal disk file, or a device like the null device or

Whats the difference between redirections “1>/dev/null 2>&1” and “ 2>&1 1>/dev/null”?

无人久伴 提交于 2021-02-04 21:37:04
问题 Whats the difference between redirections 1>/dev/null 2>&1 and 2>&1 1>/dev/null It seems 1st one displays output to stdout but not the second one. Can somebody explain ! Thanks 回答1: Expanding on Lokendra26's answer a bit: /dev/null is a special file on your system, a device for discarding anything written to it. It's common to send output there if you don't want to see it. "File" in this case, and unix terminology in general, can be both a normal disk file, or a device like the null device or