Re: sending to an xterm
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Kent Tenney wrote: > Derek Martin pizzashack.org> writes: > >> On Fri, Aug 08, 2008 at 08:25:19PM +, Kent Tenney wrote: >>> Howdy, >>> >>> I want to open an xterm, send it a command and have it execute it. >> You can't do that. xterm doesn't execute shell commands passed on >> stdin... It can, however, execute one passed on the command line. >> >> Instead of just running xterm, you can run "xterm -e 'cmd foo bar'" >> where cmd is the program to run and foo and bar are its arguments. >> The problem is that as soon as the program exits, xterm will exit >> also. >> > > OK, I see that. > > (getting off topic) > > any chance of keeping the xterm open after running the command? > > Thanks, > Kent > xterm -hold -e "whatever" > > > -- > http://mail.python.org/mailman/listinfo/python-list - -- Rich Healey - [EMAIL PROTECTED] Developer / Systems Admin - OpenPGP: 0x8C8147807 MSN: [EMAIL PROTECTED] AIM: richohealey33 irc.psych0tik.net-> #hbh #admins richohealey irc.freenode.org -> #hbh #debian PythonNinja -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkidKIAACgkQLeTfO4yBSAclUwCg3uuvxxWHgZ/vqenrmaNIV/iE ceQAn3e8oC6t0rTLtVhpeisujnqq8jlh =4s8n -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
RE: sending to an xterm
since I do not have access to xterm, here is the interactive session for spawning bash(another session if you will), sending ls command to it, and retrieving the results. things to note are: 1. after spawning expect for the prompt, timeout, and eof #which ever happens first 2. return value is the action that matched 3. if prompt matched, the 'before' has the results 4. even the command 'ls' with '\r\n' will be in the results. actual session-- [EMAIL PROTECTED]:/c/Edwin/Projects/expect $ python Python 2.5.1 (r251:54863, May 18 2007, 16:56:43) [GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import pexpect >>> c = pexpect.spawn('/bin/bash') >>> c.expect([pexpect.TIMEOUT, pexpect.EOF, '\$ ']) 2 >>> c.before '[EMAIL PROTECTED]:/c/Edwin/Projects/expect\r\n' >>> c.after '$ ' >>> c.sendline('ls') 3 >>> c.expect([pexpect.TIMEOUT, pexpect.EOF, '\$ ']) 2 >>> c.before '[EMAIL PROTECTED]:/c/Edwin/Projects/expect\r\n' >>> c.after '$ ' >>> >>> exit() [EMAIL PROTECTED]:/c/Edwin/Projects/expect $ --- good luck Edwin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kent Tenney Sent: Friday, August 08, 2008 4:25 PM To: python-list@python.org Subject: sending to an xterm Howdy, I want to open an xterm, send it a command and have it execute it. I thought pexpect would do this, but I've been unsuccessful. term = pexpect.spawn('xterm') starts an xterm, but term.sendline('ls') doesn't seem to do anything. Suggestions? Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list The information contained in this message and any attachment may be proprietary, confidential, and privileged or subject to the work product doctrine and thus protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify me immediately by replying to this message and deleting it and all copies and backups thereof. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: sending to an xterm
Derek Martin pizzashack.org> writes: > > On Fri, Aug 08, 2008 at 08:25:19PM +, Kent Tenney wrote: > > Howdy, > > > > I want to open an xterm, send it a command and have it execute it. > > You can't do that. xterm doesn't execute shell commands passed on > stdin... It can, however, execute one passed on the command line. > > Instead of just running xterm, you can run "xterm -e 'cmd foo bar'" > where cmd is the program to run and foo and bar are its arguments. > The problem is that as soon as the program exits, xterm will exit > also. > Sorry to reply before getting googly This appears to be a solution; xterm -e "ls; bash" http://www.linuxforums.org/forum/misc/115239-getting-prompt-after-xterm-e-command.html -- http://mail.python.org/mailman/listinfo/python-list
Re: sending to an xterm
Derek Martin pizzashack.org> writes: > > On Fri, Aug 08, 2008 at 08:25:19PM +, Kent Tenney wrote: > > Howdy, > > > > I want to open an xterm, send it a command and have it execute it. > > You can't do that. xterm doesn't execute shell commands passed on > stdin... It can, however, execute one passed on the command line. > > Instead of just running xterm, you can run "xterm -e 'cmd foo bar'" > where cmd is the program to run and foo and bar are its arguments. > The problem is that as soon as the program exits, xterm will exit > also. > OK, I see that. (getting off topic) any chance of keeping the xterm open after running the command? Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: sending to an xterm
On Fri, Aug 08, 2008 at 08:25:19PM +, Kent Tenney wrote: > Howdy, > > I want to open an xterm, send it a command and have it execute it. You can't do that. xterm doesn't execute shell commands passed on stdin... It can, however, execute one passed on the command line. Instead of just running xterm, you can run "xterm -e 'cmd foo bar'" where cmd is the program to run and foo and bar are its arguments. The problem is that as soon as the program exits, xterm will exit also. -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0x81CFE75D pgpMXKtm5Rt7A.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list
Re: sending to an xterm
Kent Tenney wrote: Howdy, I want to open an xterm, send it a command and have it execute it. I thought pexpect would do this, but I've been unsuccessful. term = pexpect.spawn('xterm') starts an xterm, but term.sendline('ls') doesn't seem to do anything. Suggestions? Thanks, Kent -- http://mail.python.org/mailman/listinfo/python-list expect or http://www.noah.org/wiki/Pexpect Emile -- http://mail.python.org/mailman/listinfo/python-list