473,545 Members | 2,820 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catching console output interactively


hi,

I'd like to be able to trap console output as the user writes interactively.
For example if the user press the up or down keys I'd like to be able to
catch this and return the last executed command (a bit like the bash_history
idea). Can anyone point me in the right direction?

thanks for any help,

Rob

Jul 18 '05 #1
4 1466
Hello Rob,
I'd like to be able to trap console output as the user writes interactively.
For example if the user press the up or down keys I'd like to be able to
catch this and return the last executed command (a bit like the bash_history
idea). Can anyone point me in the right direction?

Depending on what you'd like to do you can try:
"curses" module (available only on unix like systems)
wxPython
PyGame

HTH.
Miki
Jul 18 '05 #2
Dnia Fri, 16 Apr 2004 13:56:24 +0100, Byrom, R (Rob) pisze:
I'd like to be able to trap console output as the user writes
interactively. For example if the user press the up or down keys I'd
like to be able to catch this and return the last executed command (a
bit like the bash_history idea). Can anyone point me in the right
direction?


This is feature of GNU readline library, available on some Unix and
Unix-like systems. If you want to build something, that resembles Unix
shells, you can use class Cmd from cmd module. This class uses readline if
it is available on host system. I don't know, how it behaves on Windows
and if it uses capabilities of cmd.exe.

--
Jarek Zgoda
http://jpa.berlios.de/

Jul 18 '05 #3
Hello Rob,
I'd like to be able to trap console output as the user writes interactively.
For example if the user press the up or down keys I'd like to be able to
catch this and return the last executed command (a bit like the bash_history
idea). Can anyone point me in the right direction?

Depending on what you'd like to do you can try:
"curses" module (available only on unix like systems)
wxPython
PyGame

HTH.
Miki

Jul 18 '05 #4
"Byrom, R (Rob) " <R.*****@rl.ac. uk> writes:
hi,

I'd like to be able to trap console output as the user writes interactively.
For example if the user press the up or down keys I'd like to be able to
catch this and return the last executed command (a bit like the bash_history
idea). Can anyone point me in the right direction?


What platform?

Cheers,
mwh

--
There's an aura of unholy black magic about CLISP. It works, but
I have no idea how it does it. I suspect there's a goat involved
somewhere. -- Johann Hibschman, comp.lang.schem e
Jul 18 '05 #5

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

Similar topics

1
2212
by: Alexander Stante | last post by:
Hi, I know Python since about 3 days or so and I like it very much :-) I am currently tying to control an external console driven program but I have encountered some problems while trying to do so. Suppose I will try to control a program like a ftp command line client. At first I wrote something like: import popen2
1
5362
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my application (VB.NET) will start a process, redirect its stdout and capture that process' output, displaying it in a window. I've written a component...
9
2038
by: Bryan Olson | last post by:
Here's a module to show stderr output from console-less Python apps, and stay out of the way otherwise. I plan to make a ASPN recipe of it, but I thought I'd run it by this group first. To use it, import the module. That's it. Upon import it will assign sys.stderr. In the normal case, your code is perfect so nothing ever gets written to...
3
6348
by: Paul Watson | last post by:
It is clear that just using 'print' with variable names is relatively uncontrollable. However, I thought that using a format string would reign the problem in and give the desired output. Must I resort to sys.stdout.write() to control output? $ python Python 2.4.1 (#1, Jul 19 2005, 14:16:43) on linux2 Type "help", "copyright",...
5
11201
by: Barry Mossman | last post by:
Hi, can I detect whether my class is running within the context of a Console application, vs say a WinForm's application ? also does anyone know whether the compiler or runtime is smart enough to avoid the overhead of writing to the console if it is not visible, eg I am running inside a WinForm application. thanks
5
3604
by: kevin | last post by:
using VS 2003 I have a console app and writing to the console looks ugly as the line wraps at exactly 80 characters. Short of counting every character, is there an easier way to format my output to the console so that each line is intelligently broken at 80 characters or less when 80 characters falls within a word. thanks
3
1796
by: Peter A. Schott | last post by:
I know there's got to be an easy way to do this - I want a way to catch the error text that would normally be shown in an interactive session and put that value into a string I can use later. I've tried just using a catch statement and trying to convert the output to string, but this doesn't always work. I really don't have programs complex...
0
915
by: Jeff Jarrell | last post by:
I have a new project that is a console app. It is in debugging configuration. I changed the output directory to just "bin\" When I run the program from inside VS (F5) it creates the program and the vshost.exe in bin\debug. If I just do a BUILD it creates the program in the bin folder.
3
2384
by: Thomas Jansson | last post by:
Dear all I have tkinkter based frontend to a Fortran based program. I use subprocess to launch the fortran program as a child process and I wish to see the output of the fortran program as it is created in the console. The fortran program can take up to 20 minuttes to finish and at the moment the I will first see any output after the...
0
7502
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, 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...
0
7692
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7946
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6026
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5360
isladogs
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...
0
3491
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...
1
1921
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
1
1045
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
744
bsmnconsultancy
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...

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.