473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Skript that reads from Unix Pipe _AND_ interacts by getkey()

Greetings to all Python fans :-)

Is it possible to create a skript, that can read from a unix pipe
(eg.: "find -type f -name "*.ogg" | myscript.py"), _AND_ interact with
the user by waiting for keypress (eg.: getkey() funktion of a curses
screen)?

My tests failed: When I divert data via pipe to my skript and do
sys.stdin.read(), screen.getkey() always returns -1.

Has anyone an idea, how this issue can be solved? The "less" command
does exactly the same, so there should be a way.

Thanks in advance
Schwerdy
Jul 18 '05 #1
2 2157
On 27 Oct 2003 01:21:22 -0800,
sc******@web.de (schwerdy) wrote:
Is it possible to create a skript, that can read from a unix
pipe (eg.: "find -type f -name "*.ogg" | myscript.py"), _AND_
interact with the user by waiting for keypress (eg.: getkey()
funktion of a curses screen)? My tests failed: When I divert data via pipe to my skript and do
sys.stdin.read(), screen.getkey() always returns -1. Has anyone an idea, how this issue can be solved? The "less"
command does exactly the same, so there should be a way.


"less" interacts with the user through /dev/tty.

Regards,
Heather

--
Heather Coppersmith
That's not right; that's not even wrong. -- Wolfgang Pauli
Jul 18 '05 #2
> Is it possible to create a skript, that can read from a unix pipe
(eg.: "find -type f -name "*.ogg" | myscript.py"), _AND_ interact with
the user by waiting for keypress (eg.: getkey() funktion of a curses
screen)?


I resolved this issue by myself, but I don't know if this is too Quick&Dirty:

import sys
lines = sys.stdin.readlines()
sys.stdin.close()
sys.stdin = open('/dev/tty','r')

that's it. The disadvantage of this is, that the skript now only runs on unix :-(
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Frank R. Suchy | last post by:
Hi, I want a php-script to maintain (some of) "my" cron jobs. Therefore it has to modify some crontab.txt (no problem) and has to execute crontab. But since php runs as the apache-user it...
2
by: Hans Deragon | last post by:
Greetings. I am performing: commands.getstatusoutput("rsync <params>"); rsync takes a long time and prints out a steady stream of lines showing which file it is currently working on.
8
by: Neale | last post by:
In a python program, I want to do a Unix directory list and then append selected files to each other which, as you know, is just "cat filename2 >> filename1." How do I escape into the shell and...
2
by: Mohsin | last post by:
Hi all, I have a perl program which makes a user exit to the O/S (unix, solaris) to issue a O/S command. I know that the shell it invokes is NOT a korn shell, because I captured the shell info...
22
by: Ryan M | last post by:
I've been programming for a while, but most of my experience is on unix. How do C compilers work on operating systems that weren't written in C? And that have no libc? Compiling C on unix seems...
2
by: Steve R. Hastings | last post by:
While studying iterators and generator expressions, I started wishing I had some tools for processing the values. I wanted to be able to chain together a set of functions, sort of like the...
9
by: David T. Ashley | last post by:
Thanks for the helpful replies on the other thread. Essentially it was pointed out that a process with the same UID as the ones writing/reading the pipes would be able to examine the memory of the...
1
by: kardon33 | last post by:
Let me explain my problem, Im currently trying to use a Perl module that was built for a Windows OS that uses a .dll and .lib file. I have obtained the c header files that the modules were built...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.