473,471 Members | 4,648 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

sys.stdin.read() replacement

I am writing a small write-logfile script for use on the terminal. I have here
a section where the user should be able to type in several lines. I have solved
it so far by using sys.stdin.read(), which makes it possible to type in several
lines (separated by enter) and then terminate the session by typing ^D. This is
all very good. However, with this it is only possible to edit the line you are
in. If you spot an error further up in your text, you cannot get at it. Do any
of you know of a way I can do this?

Thanks,

Karin
--
Karin Lagesen,
ka***********@labmed.uio.no
Jul 18 '05 #1
2 1780
Karin Lagesen wrote:
I am writing a small write-logfile script for use on the terminal. I have here
a section where the user should be able to type in several lines. I have solved
it so far by using sys.stdin.read(), which makes it possible to type in several
lines (separated by enter) and then terminate the session by typing ^D. This is
all very good. However, with this it is only possible to edit the line you are
in. If you spot an error further up in your text, you cannot get at it. Do any
of you know of a way I can do this?

The UNIX-ish way to do this, is invoking the user's prefered editor (as
defined by the VISUAL or EDITOR environment variables) on a temporary
file and read this file when the editor terminates.
Jul 18 '05 #2
P
Karin Lagesen wrote:
I am writing a small write-logfile script for use on the terminal. I have here
a section where the user should be able to type in several lines. I have solved
it so far by using sys.stdin.read(), which makes it possible to type in several
lines (separated by enter) and then terminate the session by typing ^D. This is
all very good. However, with this it is only possible to edit the line you are
in. If you spot an error further up in your text, you cannot get at it. Do any
of you know of a way I can do this?

import readline

(I don't know if it works on windos)

Pádraig.
Jul 18 '05 #3

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

Similar topics

9
by: It's me | last post by:
Why do I get an "AttributeError: read" message when I do: import sys r=sys.stdin.read() ?? I've tried: r=sys.stdin.read(80)
3
by: Harayasu | last post by:
Hi, Using fgets() I can read from stdin and with fputs() I can write to stdout. Now I have two programs, one writing to stdin and the other one reading from stdin. And I would like the second...
6
by: Charlie Zender | last post by:
Hi, I have a program which takes the output filename argument from stdin. Once the program knows the output filename, it tries to open it. If the output file exists, the program asks the user to...
6
by: ccdrbrg | last post by:
What is the best way to protect stdin within a library? I am writing a terminal based program that provides plugin capability using the dlopen() API. Sequencing program commands (typed) and...
11
by: David Warner | last post by:
Greetings! I need to write some C code that will decide between either reading from stdin or take a file name from argv and process it. The program needs to work like all of the typical unix...
8
by: orium69 | last post by:
Hi! how could i know if it was written something in stdin since the last time i read it? Tks...
1
by: asdsd sir | last post by:
Hi!I'm new in Python and i'd like to ask some general questions about stdin,stdout... Firstly... if we type like something like : cat "file.txt"|python somefile.py #somefile.py import sys
31
by: Nikos Chantziaras | last post by:
Hello. Is there a way to check if the current process has an stdin handle? In the win32 API, one can do: _eof(_fileno(stdin)) Crucial here is that the above doesn't block. Is there a...
16
by: fbertasso | last post by:
Hi, I´m opening stdin to get a file and pass it through a pipe. razor=popen ("/var/qmail/bin/razor-check -home=/var/qmail/razor", "w"); while( (ret=fread(linha,1,sizeof(linha),stdin) ) 0 ) {...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
1
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...
0
agi2029
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,...
0
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...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.