473,386 Members | 1,801 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.

Communicating with xterm

Hi,
I am new to Pythion world.

My Objective : I want to open an Xterm and try to send message to that
xterm. I dont want to use Expect script.
I have written a small program

import os
import commands
import pty
import re
import tty

(master,slave) = pty.openpty()
print "master = %d , slave = %d" %(master, slave)
paths = os.ttyname(slave)
print "paths = %s" %(paths)
p = re.compile('/(.*)/(.*)/(.*)')
m = p.split(paths)
cmd = '-S' + str(m[3]) + '/' + str(slave)
pid = os.fork()
if pid == 0:
os.setsid()
os.dup2(slave, 0)
os.dup2(slave, 1)
os.dup2(slave, 2)
os.close(master)
os.close(slave)
os.execv('/usr/openwin/bin/xterm',["xterm" , cmd])
else :
print "xterm pid = ", pid
while True:
os.write(master,"bash")
os.fsync(master)
os.write(master,"ls")
os.fsync(master)
os.write(master,"ls")
os.fsync(master)
os.write(master,"ls")
os.fsync(master)
os.write(master,"ls")
os.fsync(master)
data = os.read(0,20)
print "data is %s" %(data)
os.write(master,data)

But It is not working. Xterm window doesnot show the Shell prompt.

Can somebody please give some clue , how to progress .
Is there some example code for xterm communication with Python code.

regards
Anirban Roy
Jul 12 '06 #1
0 1322

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

Similar topics

3
by: Leonardo Henrique Machado | last post by:
Is is possible to create a link that opens a xterm window? The person clicks on the links and a funcion calls /usr/bin/X11/xterm -e ssh <IP> which gives the person a shell on that IP...
0
by: Stelios Xanthakis | last post by:
Hi. I'm trying to open an xterm in slave mode connected to a pseudo tty with an interactive python shell. This can be useful when working in a GUI to pop up xterm'd shells. The program below is...
4
by: Dennis | last post by:
Hi, I suppose this post could fall under comp.os.linux/comp.os.unix as well, but I figured since my end goal was control from C++ code I figured this group might be the place to start. As the...
4
by: schwerdy | last post by:
Hi together, can someone provide an example of a curses application that works in a xterm that can be resized? I could not find any working example yet... Thanks in advance, Sebastian...
0
by: gimme_this_gimme_that | last post by:
I spent about an hour getting this today ... For you cygwin users who want to run db2 commands like you'd run them from a UNIX environment .... Create a...
3
by: Stan | last post by:
Hallo, I have developed an application in MS Access 2000 (Polish version) under MS Windows XP prof (also Polish). Now I would like to run this code on MS Windows XP EN and MS Access XP EN. I have...
0
by: jpaulus | last post by:
I'd like to embed an xterm into a larger qt application running on linux into which I can direct commands and allow users to interact with existing scripts that would require their command line...
20
by: valpa | last post by:
I'm a net admin for about 20 unix servers, and I need to frequently telnet on to them and configure them. It is a tiring job to open a xterm and telnet, username, password to each server. Can I...
7
by: hlubenow | last post by:
Hello, I'd like to check, if a single key is pressed on a Linux xterm. This code waits for a key to be pressed and returns the character: -------------------------------------------- ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...

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.