Hi,
I have Python embedded with my other code, and when my other code opens
a console and redirects stdout, stdin and stderr to it, then calls
PyRun_Interacti veLoop, it immediately returns with an EOF.
After some debugging the reason for this appears to be that the stdin
and stdout that the ReadLine function in the tokeniser include are not
affected by my redirection and refer to a non-terminal so don't stall
waiting for input from my console.
This is the C code, effectively. It should suffice as an
example of what I am doing, although as it is from memory,
it may have minor semantic errors, please ignore them:
/* This goes nowhere because the old stdin and stdout are
no longer valid */
printf("Test\n" );
/* This opens a console and redirects the in, out and err */
AllocConsole();
freopen("CONIN$ ", "r", stdin);
freopen("CONOUT $", "a", stdout);
freopen("CONOUT $", "a", stderr);
/* I've tested stdin, stdout and stderr at this point and they
all work correctly on the opened console window. */
printf("Test stdout working, isatty(stdin) = %d\n",
isatty(fileno(s tdin)));
/* Returns 64 */
/* This call returns immediately. The stdin and stdout when
the code gets to the actual reading, return isatty(fileno(x ))
== 0 and so it uses the non terminal reading. */
PyRun_Interacti veLoop(stdin, "Opened Console");
Can anyone help me? I have no idea how to get Python to adopt
the new stdin, stdout and stderr, but I have to assume it is
pretty straightforward .
Thanks. 0 1832 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mark McEahern |
last post by:
Is there a straightforward way to get the exit code from a windows
process?
I want to write a script that runs a bunch of .sql files against SQL
Server using osql. I want it to stop if there's an error; e.g.,
import os
import glob
server = 'foo'
|
by: Vincent Touquet |
last post by:
Hi,
In a project where I have embedded Python in a C++ application, I have
the need to replace what Python considers to be stdin, stdout and/or
stderr.
In sysmodule.c in the Python sources, I find the following lines of
code:
sysin = PyFile_FromFile(stdin, "<stdin>", "r", NULL);
|
by: Jeff Learman |
last post by:
I want to do a very simple thing in Windows. (Using Python Shell.)
I want to write a prompt to sys.stdout and read the user input.
(Ideally, without waiting for a newline.)
Here are the problems I'm encountering. Newbie problems, no doubt.
sys.stdin.read() gives me an attribute error
sys.stdin.readline() doesn't block waiting for input. And even
if it did, it would block waiting for a newline.
|
by: Jonathan Fine |
last post by:
Hello
I have written a program that interacts with a
command line program.
Roughly speaking, it mimics human interaction.
(With more speed and accuracy, less intelligence.)
It works fine under Linux, using select().
|
by: Pierre Rouleau |
last post by:
Hi all,
I have a consistent test case where os.popen3() hangs in Windows. The
system hangs when retrieving the lines from the child process stdout.
I know there were several reports related to os.popen3() hanging under
Windows in this group before.
I stumbled on a case where a piece of code works in some occasions and
hangs consistently given different data. It performs exactly the same
on 3 different computers running Windows:
| |
by: Greg Ercolano |
last post by:
When I use os.popen(cmd,'w'), I find that under windows, the stdout
of the child process disappears, instead of appearing in the DOS window
the script is invoked from. eg:
C:\type foo.py
import os
import sys
file = os.popen("nslookup", 'w')
file.write("google.com\n")
file.close()
|
by: kimonp |
last post by:
I am running on windows XP with a fresh install of wamp5 (1.7.2) and mediawiki.
I am trying to call a perl function from within php using proc_open.
The perl script is being executed and returns a successful exit value, and I can read the results it prints to STDOUT in PHP, but the perl script does not see STDIN from PHP. Since I want to use the perl script as a filter and I don't want to create an intermediary file, this is problematic....
|
by: Thomas Schreiner |
last post by:
Hi,
I'm extending a windows application (C++) by embedding Python calls. It
seems to be a known problem that windows applications detach immediately
from the calling console, so that all output to stdout (from both C++
and Python) doesn't get shown anywhere.
A workaround seems to be the allocation of a windows console and
redirecting stdout to it:
|
by: Gabriel Genellina |
last post by:
En Thu, 25 Sep 2008 09:49:31 -0300, Almar Klein <almar.klein@gmail.com>
escribió:
Use subprocess.PIPE
Usually the tricky part is to figure out exactly whether there is more
input or not. With Python it's easy, use the ps1 prompt.
--- begin ---
import sys
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |