I googled around, but couldn't understand how to solve this problem.
I have 2 scripts
# script1.py #
print 'something'
#script2.py
x=sys.stdin.rea d()
print 'passed'
if I run
script1.py | script2.py
all goes well.
But if I run just
script2.py
the program blocks waiting forever for input.
On *nix I used select.select to solve this problem, but on windows?
I read that maybe I should use, from win32api, GetStdHandle and
WaitForMultiple Objects, but how to do it it's far from my knowledge.
Any help?
Thank you,
Riccardo 6 1164
Le Mercredi 14 Juin 2006 17:13, ri*****@gmail.c om a écrit*: # script1.py # print 'something'
#script2.py x=sys.stdin.rea d()
read() will read a file object to the end, i guess you want to use readline()
instead or the builtin raw_input.
print 'passed'
if I run script1.py | script2.py all goes well.
This is because when script1.py ends, it will send an 'EOF' char to
script2.py, wich terminate the read method. But if I run just script2.py the program blocks waiting forever for input.
here, newlines ('\n'), doesn't terminate the read call, you can stop the read
by typing ctrl+d at the beginnning of a new line in a normal unix terminal.
--
_____________
Maric Michaud
_____________
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
do u really need read something even when you run the scripts2.py directly?
why not just change script2.py to
#script2.py
if __name__ == "__main__":
x=sys.stdin.rea d()
print 'passed'
else:
print 'passed from else branch'
is it what you want? or anything i misunderstand.
On 14 Jun 2006 08:13:04 -0700, ri*****@gmail.c om <ri*****@gmail. com> wrote: I googled around, but couldn't understand how to solve this problem. I have 2 scripts
# script1.py # print 'something'
#script2.py x=sys.stdin.rea d() print 'passed'
if I run script1.py | script2.py all goes well.
But if I run just script2.py the program blocks waiting forever for input.
On *nix I used select.select to solve this problem, but on windows? I read that maybe I should use, from win32api, GetStdHandle and WaitForMultiple Objects, but how to do it it's far from my knowledge.
Any help?
Thank you, Riccardo
-- http://mail.python.org/mailman/listinfo/python-list
imcs ee ha scritto: do u really need read something even when you run the scripts2.py directly? why not just change script2.py to #script2.py if __name__ == "__main__": x=sys.stdin.rea d() print 'passed' else: print 'passed from else branch'
is it what you want? or anything i misunderstand.
it won't do. clever btw.
Script2 is not a module, it's a program that _could_ receive input via
pipe.
yeah, forget my post ,it;s useless.
sorry for my thoughtless
On 14 Jun 2006 10:40:15 -0700, ri*****@gmail.c om <ri*****@gmail. com> wrote: imcs ee ha scritto:
do u really need read something even when you run the scripts2.py directly? why not just change script2.py to #script2.py if __name__ == "__main__": x=sys.stdin.rea d() print 'passed' else: print 'passed from else branch'
is it what you want? or anything i misunderstand.
it won't do. clever btw. Script2 is not a module, it's a program that _could_ receive input via pipe.
-- http://mail.python.org/mailman/listinfo/python-list
imcs ee wrote: yeah, forget my post ,it;s useless. sorry for my thoughtless On 14 Jun 2006 10:40:15 -0700, ri*****@gmail.c om <ri*****@gmail. com> wrote:
imcs ee ha scritto:
do u really need read something even when you run the scripts2.py directly? why not just change script2.py to #script2.py if __name__ == "__main__": x=sys.stdin.rea d() print 'passed' else: print 'passed from else branch'
is it what you want? or anything i misunderstand.
it won't do. clever btw. Script2 is not a module, it's a program that _could_ receive input via pipe.
It really doesn't matter *how* it receives input, whether from a pipe,
or a terminal or a redirected file.
When you run it "standalone " you should give it some input - type some
text then enter ^D (on Unix-like systems) or ^Z (on Windows). How else
do you expect read() to return anything? It *has* to read to the end fo
the file before it returns a value.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Love me, love my blog http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
Steve Holden ha scritto: When you run it "standalone " you should give it some input - type some text then enter ^D (on Unix-like systems) or ^Z (on Windows). How else do you expect read() to return anything? It *has* to read to the end fo the file before it returns a value.
regards Steve
you've got reason.
I must read my command line options, if then there is still text I use
that, otherwise I read from stdin. If nothing was piped, the user must
complete the work.
Thank you all,
Riccardo This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: FiremanSAM |
last post by:
Hai all,
I would make a ip block script for my site. The blocked ip are stored in a
file.
I have made the following script. Why does this not work. The file entries
must be stored in a array and after that i must check all the fields in the
array. Please help...
<?php
$ip = $_SERVER;
|
by: TadPole |
last post by:
Hi all,
My main problems are:::::::::
1. Set a value within a block container that can be used and changed by
subsequent templates/block-containers/tables etc..
2. get/determine/find the setting that tell the process that the new
top of the document region is now at the end of the last
block-container used, this must be set in that last block container.
3. find the value used in the 'top" setting on the prior
|
by: Michael Mair |
last post by:
Hello,
in C89 (at least in the last public draft),
"3.6.2 Compound statement, or block", we have
,---
| Syntax
|
| compound-statement:
| { declaration-list<opt> statement-list<opt> }
|
by: scottyman |
last post by:
I can't make this script work properly. I've gone as far as I can with
it and the rest is out of my ability. I can do some html editing but
I'm lost in the Java world. The script at the bottom of the html page
controls the form fields that are required. It doesn't function like
it's supposed to and I can leave all the fields blank and it still
submits the form. Also I can't get it to transfer the file in the
upload section. The file name...
|
by: Steven Bethard |
last post by:
Ok, I finally have a PEP number. Here's the most updated version of the
"make" statement PEP. I'll be posting it shortly to python-dev.
Thanks again for the previous discussion and suggestions!
PEP: 359
Title: The "make" Statement
Version: $Revision: 45366 $
Last-Modified: $Date: 2006-04-13 07:36:24 -0600 (Thu, 13 Apr 2006) $
| |
by: Fariba |
last post by:
Hello ,
I am trying to call a mthod with the following signature:
AddRole(string Group_Nam, string Description, int permissionmask);
Accroding to msdn ,you can mask the permissions using pipe symbol .for
example you can use something like this
AddRole("My Group", "Test", 0x10000000|0x00000002);
|
by: Steven Bethard |
last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The
patch is available at:
http://bugs.python.org/1472459
and I've pasted the full text below.
I've tried to be more explicit about the goals -- the make statement
is mostly syntactic sugar for::
class <name> <tuple>:
__metaclass__ = <callable>
|
by: nleahcim |
last post by:
Hi - I am starting to look at doing something that I think will be
amazingly difficult. I ideally would like to do this in C, as that is
what I am best in. I can handle C++ but I am not particuarly fond of
that language. I also have extensive experience with Javascript, HTML,
and CSS. I used to do alot of Visual Basic 6, though it's been a while.
Here's a list of what I'd like to be able to include all in one screen:
-two way serial...
|
by: HowardL |
last post by:
Hi,
I would like to be able to either pipe data into my prog from stdin or get data from a file.
If I try to check by using if( Console.In.Peek() != -1 )
{
Console.WriteLine("GOT STDIN");
return;
} ...it blocks and user must hit return to continue.
Is there a test I can do in C# that will not block?
Thanks
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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
| |