Pexpect and a Linux Terminal

asgarde at msn.com asgarde at msn.com
Tue Dec 25 10:14:00 EST 2007


On 25 déc, 09:41, "asga... at msn.com" <asga... at msn.com> wrote:
> Yes it's work ! :-D
>
> I use  prompt = '.*#' to detect the prompt expect. Thank you for you'r
> help !
>
> Vive Python et TK :-D

I have another probleme, not directly from Pexpect() function. There
is my code :

from Tkinter import *
from sys import *
import tkMessageBox
from tkColorChooser import askcolor
from tkFileDialog   import askopenfilename
import tkFileDialog as Selector
from os.path import exists, join
from os import pathsep
import pexpect
import os, sys
def test():
 cmd1="su -"
 pwd="mypass"
 prompt ='.*#'
 iso=Selector.askopenfilename(initialdir="/home/user",filetypes =
[("iso", "*.iso")])
 lbl2=Label(fen1)
 cmd2="mount -o loop "+iso+" /mnt/disk"
 child = pexpect.spawn(cmd1)
 child.expect('Mot de passe :')
 child.sendline(pwd)
 child.expect(prompt)
 child.send(cmd2)
 lbl2.configure(text=cmd2)
 lbl2.pack()
fen1=Tk()
entr1=Entry(fen1)
lbl1=Label(fen1)
entr1.pack()
lbl1.pack()
bou1= Button(fen1,text='Parcourir',command=test)
bou1.pack()
fen1.mainloop()


All that's ok when if cmd2 command like : mkdir /root/toto but when i
want to replace it for : mount loop -o /home/user/myiso.iso /mnt/disk
nothing happened :-( I tryed the command during many times and i don't
know why it doesn't work :s

if you can help me another time i will be apprecied :-P

Thank you :)



More information about the Python-list mailing list