stdout

How to get a handle on Windows STDOUT handles (in python)?

不羁的心 提交于 2019-12-18 09:46:53
问题 I am trying to get a handle on Windows stdout handles. I need to understand why there are different handles for STDOUT ( CONOUT$ ?) and how to interpret these differences. I know there are different output buffers used by the Windows API, but failt to understand (from the many MSDN docs) when and how to, use them. Using ctypes and python3, I can get 2 of these by the script below. However, running the script in (Cygwin) mintty/bash , PowerShell (6.1.1), CMD or even ConEmu , all yield slightly

How do you stream data into the STDIN of a program from different local/remote processes in Python?

杀马特。学长 韩版系。学妹 提交于 2019-12-18 09:37:11
问题 Standard streams are associated with a program. So, suppose there is a program already running in some way (I don't care how or in what way). The goal is to create pipes to the STDIN of the program from different processes (or programs) that run either locally or remotely and stream data into it asynchronously. Available information is (1) the host address and (2) the pid of the program only. How does one implement both cases in Python in this case? Edit: I should have mentioned this

how to save output from dataframe info to file a excel or text file

爷,独闯天下 提交于 2019-12-18 09:34:18
问题 How can I write df.info() to file? I would like to include this in a sheet of the excel file where I write my df to using df.to_excel . According to the docs (pandas.DataFrame.info) it returns a buf : writable buffer, defaults to sys.stdout 回答1: I would try the following: f = open('df.info', 'w+') df.info(buf=f) f.close() 来源: https://stackoverflow.com/questions/35436331/how-to-save-output-from-dataframe-info-to-file-a-excel-or-text-file

How to filter an object of devices to a single one based on hostname in powershell? [duplicate]

僤鯓⒐⒋嵵緔 提交于 2019-12-18 09:29:02
问题 This question already has an answer here : Capturing the output of a very simple power shell script (1 answer) Closed 2 months ago . I'm trying to get the sitename of a device by using the hostname of a single device from an object that contains the details of 100's of devices in Powershell. How do I filter it? The data is originally from an API and is being pulled in as Json, I've converted it using ConvertFrom-Json so it should be in an object now. I have tried piping the object through

Why does WriteFile crash when writing to the standard output?

孤者浪人 提交于 2019-12-18 07:36:47
问题 Here's a "Hello world" program that uses WinAPI's WriteFile (compiled in Microsoft Visual C++ 2008 Express): int _tmain(int argc, _TCHAR* argv[]) { wchar_t str[] = L"Hello world"; HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE); if(out && out!=INVALID_HANDLE_VALUE) { WriteFile(out, str, sizeof(str), NULL, NULL); CloseHandle(out); } return 0; } If executed in a console window, it happily greets the world. If you try to redirect its standard output, however, as in hello.exe > output.txt the

redirect stdout to tkinter text widget

三世轮回 提交于 2019-12-18 07:05:54
问题 I'm trying to redirect the stdout of a function to a tkinter text widget. The problem I am running into is that it writes each line to a new window instead of listing everything in one. The function scans a directory and lists any file that is 0k. If no files are 0k it prints that. So, the problem is that if there are 30 0k files in a directory, it will open 30 windows with a single line in each. Now, I know what the problem is. If you look in my function code Zerok() I am telling it: if os

passing \n (new line) on stdout throught sys argument

我的未来我决定 提交于 2019-12-18 06:59:28
问题 This is elementary I guess: Let's consider this snippet: for i in range(3): sys.stdout.write(str(i) + '\n') out: 0 1 2 and this: for i in range(3): sys.stdout.write(str(i) + sys.argv[1]) out (after passing \n as argument): 0\n1\n2\n So, how can I pass new-line as argument? 回答1: sys.stdout.write(str(i) + sys.argv[1].decode("string_escape")) 来源: https://stackoverflow.com/questions/5715414/passing-n-new-line-on-stdout-throught-sys-argument

Undo a newline (\n) printed to command line

旧巷老猫 提交于 2019-12-18 04:42:21
问题 printf("Error %d\n", 1); printf("\nStatus: %d%%", 50); prints Error 1 Status: 50% In this set up, is there any chance to insert Error 2\n between Error 1\n and \nStatus: 50% . I understand that \r and \b can be used to change printed text in the same line (e.g., if there is a single \n between Error 1 and Status: 50% ), but can I change text in a previous line? Thanks! 回答1: Sorry, you cannot. But you may issue system calls to clear the whole screen instead, like system("clear") (OS-dependent)

How do I chain stdout in one child process to stdin in another child in C?

主宰稳场 提交于 2019-12-18 04:23:12
问题 I've been messing around in C trying to figure out how to do this. Let's say I have my main program, the parent process. The parent creates three child processes, each of which will eventually run programs (but that's not important right now). What I'd like to do is make it so that the first child's stdout will be received by the second child's stdin. The second child's stdout will then be received by the third child's stdin. The parent process's stdin/stdout aren't messed with at all. So far

Redirect Python standard input/output to C# forms application

落爺英雄遲暮 提交于 2019-12-18 03:01:47
问题 I apologize if this is a duplicate question, I searched a bit and couldn't find anything similar - I have a Python library that connects to my C# application via a socket in order to allow simple Python scripting (IronPython isn't an option right now for a couple of reasons). I would like to create a Windows Forms control that would be basically a graphical front-end for the Python interpreter, so that the user could run the interpreter without having to have a separate console window open. I