stdout

Redirect STDOUT and STDERR to socket in C?

China☆狼群 提交于 2019-11-29 21:17:55
问题 I am trying to redirect STDOUT AND STDERR to a socket. I did: if(fork() == 0) { dup2(newsock, STDOUT_FILENO); dup2(newsock, STDERR_FILENO); execvp(); } Somehow, it only showed the first little part of the output. for example, it showed on "mkdir" when I try to execute ls or mkdir. What's the problem? I tried the flollowing it works, but I can only redirect one of STDOUT or STDERR close(1); dup(newsock); Thanks a lot. 回答1: Your use of dup2() looks fine, so the problem is probably elsewhere.

How do you edit existing text (and move the cursor around) in the terminal?

你说的曾经没有我的故事 提交于 2019-11-29 20:30:27
I saw this demo once that printed out a paragraph of text (like you'd get when typing some-command --help ), and it then jumped back up to a couple keywords in the text and changed the text color, after it was already printed out in the terminal . That seems crazy to me. How did they do that? Starting to think about it, I guess stdout and stdin are technically an "IO stream", so maybe that's a persistent variable that keeps track of the position of a cursor? I remember doing something like that when building a language parser. The goal would be this: say you type the following into the console

Opening a TStream on stdin/stdout in a Delphi console app

孤街醉人 提交于 2019-11-29 20:22:08
I'm trying to write a Delphi console application that creates a TStream for its standard input, and another TStream for its standard output. (It will be launched by a host app with its input and output redirected to pipes, and will be passing binary data to/from that host app, so TStream will be much better-suited to the task than ReadLn/WriteLn.) How do I go about opening a TStream on standard input or standard output? Allen Bauer Off the top of my head: InputStream := THandleStream.Create(GetStdHandle(STD_INPUT_HANDLE)); OutputStream := THandleStream.Create(GetStdHandle(STD_OUTPUT_HANDLE));

Linux/Perl: Additional output buffers other than STDOUT and STDERR?

穿精又带淫゛_ 提交于 2019-11-29 19:16:48
问题 Out of curiosity, is it possible to create, instantiate, or otherwise access additional output buffers besides STDOUT and STDERR from within a Perl script? The use case would be additional outputs to pipe in to files or other commands, eg ./doublerainbow.pl 3>full_on.txt 4>all_the_way!.txt 回答1: Absolutely. The open command with the >&= mode allows you to open filehandles on arbitrary file descriptors. # perl 4fd.pl > file1 2> file2 3> file3 4> file4 5< file5 open STDFOO, '>&=3'; open STDBAR,

Not able to send commands to cmd.exe process

為{幸葍}努か 提交于 2019-11-29 18:49:26
I am trying to send commands to an open cmd.exe process using StandardInput.WriteLine(str) , however none of the commands seem to be sent. First I open a process, with a global variable p ( Process p ). p = new Process() { StartInfo = { CreateNoWindow = true, UseShellExecute = false, RedirectStandardError = true, RedirectStandardInput = true, RedirectStandardOutput = true, FileName = @"cmd.exe", Arguments = "/C" //blank arguments } }; p.Start(); p.WaitForExit(); After, I try to send a command using a simple method, that logs the result in a text box. private void runcmd(string command) { p

Call an exe from Java with passing parameters with writing to stdout and reading from stdin

给你一囗甜甜゛ 提交于 2019-11-29 18:09:48
I have read this question: Java Programming: call an exe from Java and passing parameters And this answer is good enough https://stackoverflow.com/a/5604756/2674303 But I additionally want to pass parameters to stdin of external process and read from stdout of this process. How can I do this? My efforts : main method: public class ProcessBuilderTest { public static void main(String[] args) throws IOException, InterruptedException { ProcessBuilder pb = new ProcessBuilder("C:\\Program Files\\Java\\jdk1.8.0_111\\bin\\java", "-cp", //class path key "C:\\Users\\redwhite\\IdeaProjects\\HelloMyWorld\

Tkinter subprocess locking GUI and not returning stdout to text

别说谁变了你拦得住时间么 提交于 2019-11-29 17:37:32
I've been fighting with Tkinter for a while now and have exhausted most the resources I have for referencing this. I've found a couple similar topics here but none quite bring me to where I need to be. I've got a long running python script and I was hoping to build a gui to interact with it some. I'm currently trying to pipe the data from the CLI back into the GUI but can't seem to get any of the data and the GUI locks when the subprocess is called. I'm pretty new with python and on stack overflow, so I apologize if I have missed something stupid or not asked the question in the right way.

Sending JSON from Python to Node via child_process gets truncated if too long, how to fix?

孤人 提交于 2019-11-29 17:21:20
My Node & Python backend is running just fine, but I now encountered an issue where if a JSON I'm sending from Python back no Node is too long, it gets split into two and my JSON.parse at the Node side fails. How should I fix this? For example, the first batch clips at ... [1137.6962355826706, -100.78015825640887], [773.3834338399517, -198 and the second one has the remaining few entries .201506231888], [-87276.575065248, -60597.8827676457], [793.1850250453127, -192.1674702207991], [1139.4465453979683, -100.56741252031816], [780.498416769341, -196.04064849430705]]} Do I have to create some

IOError Input/Output Error When Printing

南笙酒味 提交于 2019-11-29 17:01:45
问题 I have inherited some code which is periodically (randomly) failing due to an Input/Output error being raised during a call to print. I am trying to determine the cause of the exception being raised (or at least, better understand it) and how to handle it correctly. When executing the following line of Python (in a 2.6.6 interpreter, running on CentOS 5.5): print >> sys.stderr, 'Unable to do something: %s' % command The exception is raised (traceback omitted): IOError: [Errno 5] Input/output

Possible to capture PHP echo output?

Deadly 提交于 2019-11-29 16:57:27
问题 So I have a function such as: public static function UnorderedList($items, $field, $view = false){ if(count($items) > 0){ echo '<ul>'; foreach($items as $item){ echo '<li>'; if($view){ echo '<a href="'.$view.'id='.$item->sys_id.'" title="View Item">'.$item->$field.'</a>'; }else{ echo $item->$field; } echo '</li>'; } echo '</ul>'; }else{ echo '<p>No Items...</p>'; } } This function loops over some items and renders a unordered list. What I am wondering is if its possible to capture the echo