Redirect os.system output
I would like to redirect the output from os.system to a variable, but am having trouble. I tried using os.popen(..).read() ...but that doesn't give me exactly what i want. ..this is windows by the way. For example: tmp = os.popen("hostname").read() ...works as expected. however, tmp = os.popen("cmd").read() ...i would like to have access to the cmd process...i.e. enter commands like a normal command line. os.system() allows this, but i dont want output to the screen..i wanna store it to a variable. then send content of variable elsewhere, receive more input and submit it. almost emulate the windows command prompt. any ideas? -- http://mail.python.org/mailman/listinfo/python-list
Re: Redirect os.system output
Any other ideas? or examples of using subprocess to do what I was asking? Kent Johnson wrote: > jas wrote: > > I would like to redirect the output from os.system to a variable, but > > am having trouble. I tried using os.popen(..).read() ...but that > > doesn't give me exactly what i want. > > Here is an example using subprocess: > http://groups.google.com/group/comp.lang.python/msg/9fa3a3c287e8e2a3?hl=en&; > > Kent > > > > > ..this is windows by the way. > > > > For example: > > tmp = os.popen("hostname").read() > > > > ...works as expected. > > > > however, > > > > tmp = os.popen("cmd").read() > > ...i would like to have access to the cmd process...i.e. enter commands > > like a normal command line. os.system() allows this, but i dont want > > output to the screen..i wanna store it to a variable. then send > > content of variable elsewhere, receive more input and submit it. > > almost emulate the windows command prompt. > > > > any ideas? > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Redirect os.system output
I see that, although I don't totall grasp the code. However, I am looking to basically emulate a command prompt. i.e. everything u see in the windows command prompt should be displayed back in python. How can I do it without files? Kent Johnson wrote: > jas wrote: > > Any other ideas? or examples of using subprocess to do what I was > > asking? > > Actually I thought I was giving an example of what you were asking: > - on windows > - send a series of commands to a command process > - capture the result to a variable > > The example I referenced sends a series of HELP commands to cmd.exe, captures > the output of the commands and saves it to a file. > > What did I miss? > > Kent > > > > > > > Kent Johnson wrote: > > > >>jas wrote: > >> > >>>I would like to redirect the output from os.system to a variable, but > >>>am having trouble. I tried using os.popen(..).read() ...but that > >>>doesn't give me exactly what i want. > >> > >>Here is an example using subprocess: > >>http://groups.google.com/group/comp.lang.python/msg/9fa3a3c287e8e2a3?hl=en&; > >> > >>Kent > >> > >> > >>>..this is windows by the way. > >>> > >>>For example: > >>>tmp = os.popen("hostname").read() > >>> > >>>...works as expected. > >>> > >>>however, > >>> > >>>tmp = os.popen("cmd").read() > >>>...i would like to have access to the cmd process...i.e. enter commands > >>>like a normal command line. os.system() allows this, but i dont want > >>>output to the screen..i wanna store it to a variable. then send > >>>content of variable elsewhere, receive more input and submit it. > >>>almost emulate the windows command prompt. > >>> > >>>any ideas? > >>> > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Redirect os.system output
Ok, I tried this... C:\>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import subprocess as sp >>> p = sp.Popen("cmd", stdout=sp.PIPE) >>> >>> result = p.communicate("ipconfig") 'result' is not recognized as an internal or external command, operable program or batch file. >>> basically I was opening to send the "ipconfig" command to cmd.exe and store the result in the "result" variable. But you can see there was an error with result. Ideas? jas wrote: > I see that, although I don't totall grasp the code. However, I am > looking to basically emulate a command prompt. i.e. everything u see > in the windows command prompt should be displayed back in python. > > How can I do it without files? > > Kent Johnson wrote: > > jas wrote: > > > Any other ideas? or examples of using subprocess to do what I was > > > asking? > > > > Actually I thought I was giving an example of what you were asking: > > - on windows > > - send a series of commands to a command process > > - capture the result to a variable > > > > The example I referenced sends a series of HELP commands to cmd.exe, > > captures the output of the commands and saves it to a file. > > > > What did I miss? > > > > Kent > > > > > > > > > > > Kent Johnson wrote: > > > > > >>jas wrote: > > >> > > >>>I would like to redirect the output from os.system to a variable, but > > >>>am having trouble. I tried using os.popen(..).read() ...but that > > >>>doesn't give me exactly what i want. > > >> > > >>Here is an example using subprocess: > > >>http://groups.google.com/group/comp.lang.python/msg/9fa3a3c287e8e2a3?hl=en&; > > >> > > >>Kent > > >> > > >> > > >>>..this is windows by the way. > > >>> > > >>>For example: > > >>>tmp = os.popen("hostname").read() > > >>> > > >>>...works as expected. > > >>> > > >>>however, > > >>> > > >>>tmp = os.popen("cmd").read() > > >>>...i would like to have access to the cmd process...i.e. enter commands > > >>>like a normal command line. os.system() allows this, but i dont want > > >>>output to the screen..i wanna store it to a variable. then send > > >>>content of variable elsewhere, receive more input and submit it. > > >>>almost emulate the windows command prompt. > > >>> > > >>>any ideas? > > >>> > > > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Redirect os.system output
doesn't sound to encouraging :) How about something with os.popen? in = os.popen("cmd", "w") in.write("hostname") I tried this, and I get "IOError: [Errno 22] Invalid Argument" I am not sure why this isnt working. Steve Holden wrote: > jas wrote: > > Ok, I tried this... > > > > C:\>python > > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] > > on win32 > > Type "help", "copyright", "credits" or "license" for more information. > > > >>>>import subprocess as sp > >>>>p = sp.Popen("cmd", stdout=sp.PIPE) > >>>> > >>>>result = p.communicate("ipconfig") > > > > 'result' is not recognized as an internal or external command, > > operable program or batch file. > > > > > > > > basically I was opening to send the "ipconfig" command to cmd.exe and > > store the result in the "result" variable. But you can see there was > > an error with result. > > > It looks to me like the line you thought you were typing at the Python > command interpreter actually got snagged by the command processor you > just ran, which presumably is taking its input from the console just > like Python is. > > > Ideas? > > > Haven't used subprocess much yet, but I will just mention that this kind > of thing always looks easy in principle and turns out to be surprisingly > gnarly and difficult in practice. > > I'm not suggesting you shouldn't continue, but you are going to learn a > *lot* as you proceed. Good luck. > > regards > Steve > [...] > -- > Steve Holden +44 150 684 7255 +1 800 494 3119 > Holden Web LLC www.holdenweb.com > PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list
Read/Write from/to a process
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE) p.stdin.write("hostname\n") however, it doesn't seem to work. I think the cmd.exe is catching it. I also tried f = open("out.txt", "w") sys.stdout = f os.system("cmd.exe") ..but out.txt didn't contain any output from cmd.exe So, how can I create a process (in this case, cmd.exe) on Windows and be able to read/write from/to it? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Redirect os.system output
Kent, Yes, your example does work. So did os.popen...however, the problem is specific to "cmd.exe". Have you tried that yet? Thanks! Kent Johnson wrote: > jas wrote: > > Ok, I tried this... > > > > C:\>python > > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] > > on win32 > > Type "help", "copyright", "credits" or "license" for more information. > > > >>>>import subprocess as sp > >>>>p = sp.Popen("cmd", stdout=sp.PIPE) > >>>> > >>>>result = p.communicate("ipconfig") > > > > 'result' is not recognized as an internal or external command, > > operable program or batch file. > > > > > > > > basically I was opening to send the "ipconfig" command to cmd.exe and > > store the result in the "result" variable. But you can see there was > > an error with result. > > This works for me: > import subprocess as sp > p = sp.Popen("ipconfig", stdout=sp.PIPE) > result = p.communicate()[0] > print result > > Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Read/Write from/to a process
Thanks, that is certainly a start. As you mentioned, the "cd" could is an issue. Perhaps checking to see if the line ends with ">" is sufficient? Dennis Lee Bieber wrote: > On 24 Oct 2005 07:20:42 -0700, "jas" <[EMAIL PROTECTED]> declaimed the > following in comp.lang.python: > > > Hi, > > I would like to start a new process and be able to read/write from/to > > it. I have tried things like... > > > > import subprocess as sp > > p = sp.Popen("cmd.exe", stdout=sp.PIPE) > > p.stdin.write("hostname\n") > > > > however, it doesn't seem to work. I think the cmd.exe is catching it. > > One: you didn't read any of the "returned" output... > > Two: the output only seems to be available upon EOF, which means the > spawned command processor has to exit first... Though you CAN read one > character at a time, and then have to build lines and expected prompt > strings... > > > This seems to work: > -=-=-=-=-=-=-=-=- > import subprocess > import os > > PROMPT = os.getcwd() + ">" > > def getLine(proc): > ld = [] > while True: > c = proc.stdout.read(1) > if c == "\r": continue #skip Windows > if c != "\n": ld.append(c) #save all but > if c is None or c == "\n" or c == ">": break > ln = "".join(ld) > return ln > > p = subprocess.Popen("cmd.exe", stdout=subprocess.PIPE, stdin = > subprocess.PIPE) > > print " START of captured output" > while True: > ln = getLine(p) > print ln > if ln == PROMPT: break > print " END of captured output" > > p.stdin.write("ipconfig\n") > print " START of captured output" > while True: > ln = getLine(p) > print ln > if ln == PROMPT: break > print " END of captured output" > > p.stdin.write("dir\n") > print " START of captured output" > while True: > ln = getLine(p) > print ln > if ln == PROMPT: break > print " END of captured output" > > p.stdin.write("exit\n") > -=-=-=-=-=-=-=-=-=- > E:\UserData\Dennis Lee Bieber\My Documents>python script1.py > START of captured output > Microsoft Windows XP [Version 5.1.2600] > (C) Copyright 1985-2001 Microsoft Corp. > > E:\UserData\Dennis Lee Bieber\My Documents> > END of captured output > START of captured output > ipconfig > > Windows IP Configuration > > > Ethernet adapter Local Area Connection: > > Connection-specific DNS Suffix . : > IP Address. . . . . . . . . . . . : 192.168.1.100 > Subnet Mask . . . . . . . . . . . : 255.255.255.0 > IP Address. . . . . . . . . . . . : fe80::211:11ff:fee1:f303%4 > Default Gateway . . . . . . . . . : 192.168.1.1 > > Tunnel adapter Teredo Tunneling Pseudo-Interface: > > Connection-specific DNS Suffix . : > IP Address. . . . . . . . . . . . : > 3ffe:831f:4004:1956:0:fbde:bd0a:e50b > IP Address. . . . . . . . . . . . : fe80::5445:5245:444f%5 > Default Gateway . . . . . . . . . : :: > > Tunnel adapter Automatic Tunneling Pseudo-Interface: > > Connection-specific DNS Suffix . : > IP Address. . . . . . . . . . . . : fe80::5efe:192.168.1.100%2 > Default Gateway . . . . . . . . . : > > E:\UserData\Dennis Lee Bieber\My Documents> > END of captured output > START of captured output > dir > Volume in drive E is Data > Volume Serial Number is 2626-D991 > > Directory of E:\UserData\Dennis Lee Bieber\My Documents > > 10/24/2005 09:23 AM > . > 10/24/2005 09:23 AM > .. > 07/25/2005 10:39 PM > .metadata > 10/06/2005 09:54 AM > Ada Progs > 08/13/2005 02:01 PM > Agent Data > 10/21/2005 09:29 AM 421,820 apress_offer.pdf > 07/03/2005 11:36 AM 132 cp.py > 07/17/2005 12:25 PM > Cyberlink > 07/06/2005 09:32 AM 102,400 db1.mdb > 07/26/2005 12:20 AM26,614 eclipse_code.xml > 10/24/2005 01:08 AM > Eudora > 06/24/2005 08:50 PM 667 fake_oosums.ads > 06/24/2005 08:50 PM 695 fake_oosums.ali > 09/06/2005 09:01 PM > Genealogy > 07/13/2005 10:56 PM > HomeSite > 05/08/2005 01:05 PM > Investing > 10/21/2005 10:04 PM > Java Progs > 08/04/2005 10:13 PM
Re: Read/Write from/to a process
actually, i can't check for ">" only because if you a dir, a line can end with a > but is not the end of the output jas wrote: > Thanks, that is certainly a start. As you mentioned, the "cd" could is > an issue. > > Perhaps checking to see if the line ends with ">" is sufficient? > > Dennis Lee Bieber wrote: > > On 24 Oct 2005 07:20:42 -0700, "jas" <[EMAIL PROTECTED]> declaimed the > > following in comp.lang.python: > > > > > Hi, > > > I would like to start a new process and be able to read/write from/to > > > it. I have tried things like... > > > > > > import subprocess as sp > > > p = sp.Popen("cmd.exe", stdout=sp.PIPE) > > > p.stdin.write("hostname\n") > > > > > > however, it doesn't seem to work. I think the cmd.exe is catching it. > > > > One: you didn't read any of the "returned" output... > > > > Two: the output only seems to be available upon EOF, which means the > > spawned command processor has to exit first... Though you CAN read one > > character at a time, and then have to build lines and expected prompt > > strings... > > > > > > This seems to work: > > -=-=-=-=-=-=-=-=- > > import subprocess > > import os > > > > PROMPT = os.getcwd() + ">" > > > > def getLine(proc): > > ld = [] > > while True: > > c = proc.stdout.read(1) > > if c == "\r": continue #skip Windows > > if c != "\n": ld.append(c) #save all but > > if c is None or c == "\n" or c == ">": break > > ln = "".join(ld) > > return ln > > > > p = subprocess.Popen("cmd.exe", stdout=subprocess.PIPE, stdin = > > subprocess.PIPE) > > > > print " START of captured output" > > while True: > > ln = getLine(p) > > print ln > > if ln == PROMPT: break > > print " END of captured output" > > > > p.stdin.write("ipconfig\n") > > print " START of captured output" > > while True: > > ln = getLine(p) > > print ln > > if ln == PROMPT: break > > print " END of captured output" > > > > p.stdin.write("dir\n") > > print " START of captured output" > > while True: > > ln = getLine(p) > > print ln > > if ln == PROMPT: break > > print " END of captured output" > > > > p.stdin.write("exit\n") > > -=-=-=-=-=-=-=-=-=- > > E:\UserData\Dennis Lee Bieber\My Documents>python script1.py > > START of captured output > > Microsoft Windows XP [Version 5.1.2600] > > (C) Copyright 1985-2001 Microsoft Corp. > > > > E:\UserData\Dennis Lee Bieber\My Documents> > > END of captured output > > START of captured output > > ipconfig > > > > Windows IP Configuration > > > > > > Ethernet adapter Local Area Connection: > > > > Connection-specific DNS Suffix . : > > IP Address. . . . . . . . . . . . : 192.168.1.100 > > Subnet Mask . . . . . . . . . . . : 255.255.255.0 > > IP Address. . . . . . . . . . . . : fe80::211:11ff:fee1:f303%4 > > Default Gateway . . . . . . . . . : 192.168.1.1 > > > > Tunnel adapter Teredo Tunneling Pseudo-Interface: > > > > Connection-specific DNS Suffix . : > > IP Address. . . . . . . . . . . . : > > 3ffe:831f:4004:1956:0:fbde:bd0a:e50b > > IP Address. . . . . . . . . . . . : fe80::5445:5245:444f%5 > > Default Gateway . . . . . . . . . : :: > > > > Tunnel adapter Automatic Tunneling Pseudo-Interface: > > > > Connection-specific DNS Suffix . : > > IP Address. . . . . . . . . . . . : fe80::5efe:192.168.1.100%2 > > Default Gateway . . . . . . . . . : > > > > E:\UserData\Dennis Lee Bieber\My Documents> > > END of captured output > > START of captured output > > dir > > Volume in drive E is Data > > Volume Serial Number is 2626-D991 > > > > Directory of E:\UserData\Dennis Lee Bieber\My Documents > > > > 10/24/2005 09:23 AM > > . > > 10/24/2005 09:23 AM > > .. > > 07/25/2005 10:39 PM > > .metadata > > 10/06/2005 09:54 AM > > Ada Progs > > 08/13/
Re: Read/Write from/to a process
What about having a thread which reads from subprocess.Popen()'s stdout...instead of read/write, read/write. just always read, and write when needed? any comments on that idea? jas wrote: > actually, i can't check for ">" only because if you a dir, a line can > end with a > but is not the end of the output > > jas wrote: > > Thanks, that is certainly a start. As you mentioned, the "cd" could is > > an issue. > > > > Perhaps checking to see if the line ends with ">" is sufficient? > > > > Dennis Lee Bieber wrote: > > > On 24 Oct 2005 07:20:42 -0700, "jas" <[EMAIL PROTECTED]> declaimed the > > > following in comp.lang.python: > > > > > > > Hi, > > > > I would like to start a new process and be able to read/write from/to > > > > it. I have tried things like... > > > > > > > > import subprocess as sp > > > > p = sp.Popen("cmd.exe", stdout=sp.PIPE) > > > > p.stdin.write("hostname\n") > > > > > > > > however, it doesn't seem to work. I think the cmd.exe is catching it. > > > > > > One: you didn't read any of the "returned" output... > > > > > > Two: the output only seems to be available upon EOF, which means the > > > spawned command processor has to exit first... Though you CAN read one > > > character at a time, and then have to build lines and expected prompt > > > strings... > > > > > > > > > This seems to work: > > > -=-=-=-=-=-=-=-=- > > > import subprocess > > > import os > > > > > > PROMPT = os.getcwd() + ">" > > > > > > def getLine(proc): > > > ld = [] > > > while True: > > > c = proc.stdout.read(1) > > > if c == "\r": continue #skip Windows > > > if c != "\n": ld.append(c) #save all but > > > if c is None or c == "\n" or c == ">": break > > > ln = "".join(ld) > > > return ln > > > > > > p = subprocess.Popen("cmd.exe", stdout=subprocess.PIPE, stdin = > > > subprocess.PIPE) > > > > > > print " START of captured output" > > > while True: > > > ln = getLine(p) > > > print ln > > > if ln == PROMPT: break > > > print " END of captured output" > > > > > > p.stdin.write("ipconfig\n") > > > print " START of captured output" > > > while True: > > > ln = getLine(p) > > > print ln > > > if ln == PROMPT: break > > > print " END of captured output" > > > > > > p.stdin.write("dir\n") > > > print " START of captured output" > > > while True: > > > ln = getLine(p) > > > print ln > > > if ln == PROMPT: break > > > print " END of captured output" > > > > > > p.stdin.write("exit\n") > > > -=-=-=-=-=-=-=-=-=- > > > E:\UserData\Dennis Lee Bieber\My Documents>python script1.py > > > START of captured output > > > Microsoft Windows XP [Version 5.1.2600] > > > (C) Copyright 1985-2001 Microsoft Corp. > > > > > > E:\UserData\Dennis Lee Bieber\My Documents> > > > END of captured output > > > START of captured output > > > ipconfig > > > > > > Windows IP Configuration > > > > > > > > > Ethernet adapter Local Area Connection: > > > > > > Connection-specific DNS Suffix . : > > > IP Address. . . . . . . . . . . . : 192.168.1.100 > > > Subnet Mask . . . . . . . . . . . : 255.255.255.0 > > > IP Address. . . . . . . . . . . . : fe80::211:11ff:fee1:f303%4 > > > Default Gateway . . . . . . . . . : 192.168.1.1 > > > > > > Tunnel adapter Teredo Tunneling Pseudo-Interface: > > > > > > Connection-specific DNS Suffix . : > > > IP Address. . . . . . . . . . . . : > > > 3ffe:831f:4004:1956:0:fbde:bd0a:e50b > > > IP Address. . . . . . . . . . . . : fe80::5445:5245:444f%5 > > > Default Gateway . . . . . . . . . : :: > > > > > > Tunnel adapter Automatic Tunneling Pseudo-Interface: > > > > > > Connection-specific DNS Suffi
Re: Redirect os.system output
Paul, I did ceck out the PExpect, however, I thought it was not ported for Windows. Did you find a ported version? If not, what did you have to do to be able to use it? Thanks Paul Dale wrote: > You might want to try python expect which gives you a very simple and > scriptable interface to a process. > > http://pexpect.sourceforge.net/ > > I've been using it on windows to automate a few things. > > Cheers, > > Paul > > jas wrote: > > >Kent, > > Yes, your example does work. So did os.popen...however, the problem > >is specific to "cmd.exe". > > Have you tried that yet? > > > >Thanks! > > > >Kent Johnson wrote: > > > > > >>jas wrote: > >> > >> > >>>Ok, I tried this... > >>> > >>>C:\>python > >>>Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] > >>>on win32 > >>>Type "help", "copyright", "credits" or "license" for more information. > >>> > >>> > >>> > >>>>>>import subprocess as sp > >>>>>>p = sp.Popen("cmd", stdout=sp.PIPE) > >>>>>> > >>>>>>result = p.communicate("ipconfig") > >>>>>> > >>>>>> > >>>'result' is not recognized as an internal or external command, > >>>operable program or batch file. > >>> > >>> > >>> > >>>basically I was opening to send the "ipconfig" command to cmd.exe and > >>>store the result in the "result" variable. But you can see there was > >>>an error with result. > >>> > >>> > >>This works for me: > >>import subprocess as sp > >>p = sp.Popen("ipconfig", stdout=sp.PIPE) > >>result = p.communicate()[0] > >>print result > >> > >>Kent > >> > >> > > > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Read/Write from/to a process
So it seems there is no good way to handle "interactive" processes on windows using python. By interactive I mean processes/commands that require user interaction, such as telnet or del (to delete a file or directory sometimes you need to confirm with a yes or no), date, etc. os.system gives the exact behavior, but you can't redirec the output. pexpect isn't supported on windows. Even with subprocess you can't handle all/most cases..since you have to do things like look for he prompt. I modified the original suggestion so it would update the prompt, in case the user did a "cd.." ..which works fine now. However, if a user tries to do, "del tmp123" ...windows prompts for a "are you sure you want to delete... Y/N?" ...so the code hangs. I can't believe no one else has done this yet..or if they have, it hasn't been widely discussed. Any other suggestions? -- http://mail.python.org/mailman/listinfo/python-list
Re: Read/Write from/to a process
Steve Holden wrote: > Look at how you might do it in other languages. Then you'll realise this > isn't (just) a Python problem. Yea your right. However, for example, in Java, one can use the Process class, and then read from the stream until its the end (i.e. -1 is returned). However, with Python when reading from subprocess.Popen.stdout ...I don't know when to stop (except for looking for a ">" or something). Is there a standard, like read until "-1" or something? As I mentioned, os.system("cmd") gives me exactly the output/interactivity I need...but I can't redirect the output. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
select.select() on windows
I am currently using subprocess to execute a command. Then I read from it's stdout...however, this is hanging on a read..waiting for more bytes. So what I would like is to timeout...and select.selec() seems to be what I need. Except I don't have a socket, i have stdout. Any suggestions on how to do a timeout like select.select with stdout? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Redirect os.system output
Paul Dale wrote: > pexpect is POSIX compliant and works under Cygwin. I haven't tried it > under pythonw. Well if I want my code to run on other computers, then they'd have to run it under Cygwin right? -- http://mail.python.org/mailman/listinfo/python-list
Client/Server socket send user input
I have a basic client/server socket situation setupwhere the server accepts a connection and then waits for commands. On the client side, I create a socket, connect to the server...then I pass the socket to a class which just reads from the socket (in a thread). class Reader(Thread): def run(self): while 1: print self.sock.recv(1), Now, when the server sends back a message, and needs input back the reader hangs at the sock.recv line...which is fine, and expected. However, I want to be able to type something into the console at that point and hit enter, and have it sent to the server. In my client class I tried something like... class Client(Thread): def run(self): reader = Reader(self.sock) reader.start() while 1: x = raw_input("go>") self.sock.send(x) print "sent", x However, in order to see "go>" ..I have to hit enter first, then type in my command and hit enter to send. I just want to type and hit enter. Any ideas/suggestions? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Read/Write from/to a process
I have setup multiple threads and a queue...which is working pretty good. But I have one other issue...I have a new thread (since it is different issue) here: http://groups.google.com/group/comp.lang.python/browse_frm/thread/ec81d8982d1a0130 if you get chance, would you mind checking that out. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Read/Write from/to a process
I have setup multiple threads and a queue...which is working pretty good. But I have one other issue...I have a new thread (since it is different issue) here: http://groups.google.com/group/comp.lang.python/browse_frm/thread/ec81d8982d1a0130 if you get chance, would you mind checking that out. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Client/Server socket send user input
I even tried inserting a "\r" or "\r\n" or "\n" to stdout, also tried the same using msvcrt.putch() ...but no luck. I still have to hit enter to get the prompt , where I can then type a command and hit enter. For example, I get this displayed: [example] Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\>[cursor_is_here] [/example] ...so I type something like.."ver" but I get [example] Traceback (most recent call last): File "", line 1, in ? NameError: name 'ver' is not defined >>> [/example] Now, if I start over and have... [example] Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\>[cursor_is_here] [/example] ..and I press the Enter key I end up with [example] Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\> >>>[cursor_is_here] [/example] So, I get the prompt, I hit enter, which then displays the ">>>" ..and if I type "ver" there, I get back what I expect. I just wish I didn't have to hit enter before being able to type a command. -- http://mail.python.org/mailman/listinfo/python-list
Re: Client/Server socket send user input
Dennis, Thanks. That certainly looks like it could work. I understand about the interactive shell and my app going back and forth with the reads/writes. When my program runs it won't be used in an interactive python shell, but that is the only way I know of to really test it. -- http://mail.python.org/mailman/listinfo/python-list
DrPython - auto complete
Hi, I just started to use DrPython and I have installed the CodeCompletion plugin. I am using DrPython 161 (on windows) with wxPython 2.6.1. Anyhow, when I try something like x = [] x. ...it pops up "x.filename", "x.prepend" and "x.word". Shouldn't it show "x.append", "x.pop", etc? Just curious if anyone else uses this and has this problem. Or maybe the code completion doesn't work like I expect. -- http://mail.python.org/mailman/listinfo/python-list