Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

popen and two-way communication

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


stephendotboulet at motorola_

Oct 18, 2004, 3:36 PM

Post #1 of 5 (829 views)
Permalink
popen and two-way communication

I'd like to use popen for a little script to call gnu privacy guard and
display decrypted text to a window.

Working from the dos prompt I can type in:

"gpg -d <filename>"

But then gpg then comes back at me with something like:

"""
You need a passphrase to unlock the secret key for
user: "xxxx <xx [at] somewhere>"
1024-bit ELG-E key, ID xxxxxx, created 2004-04-27 (main key ID xxxxxx)

Enter passphrase:
"""

After entering the passphrase the decrypted text gets dumped to the console.

How do I do this with popen?

Stephen

(Too bad the pexpect module doesn't work under windows.)
--
http://mail.python.org/mailman/listinfo/python-list


cmkleffner at gmx

Oct 19, 2004, 4:55 AM

Post #2 of 5 (781 views)
Permalink
Re: popen and two-way communication [In reply to]

You may be interested in the new subprocess module:

1) PEP:
http://www.python.org/dev/doc/devel/whatsnew/node8.html

2) source code:
http://www.lysator.liu.se/~astrand/popen5/

3) Windows builds (pre Python-2.4):
http://effbot.org/downloads/#subprocess

Regards

Carl

Stephen Boulet <stephendotboulet [at] motorola_> wrote in message news:<cl1gmk$rgq$1 [at] newshost>...
> I'd like to use popen for a little script to call gnu privacy guard and
> display decrypted text to a window.
>
> Working from the dos prompt I can type in:
>
> "gpg -d <filename>"
>
> But then gpg then comes back at me with something like:
>
> """
> You need a passphrase to unlock the secret key for
> user: "xxxx <xx [at] somewhere>"
> 1024-bit ELG-E key, ID xxxxxx, created 2004-04-27 (main key ID xxxxxx)
>
> Enter passphrase:
> """
>
> After entering the passphrase the decrypted text gets dumped to the console.
>
> How do I do this with popen?
>
> Stephen
>
> (Too bad the pexpect module doesn't work under windows.)
--
http://mail.python.org/mailman/listinfo/python-list


stephendotboulet at motorola_

Oct 19, 2004, 10:40 AM

Post #3 of 5 (782 views)
Permalink
Re: popen and two-way communication [In reply to]

cmkl wrote:

> You may be interested in the new subprocess module:
>
> 1) PEP:
> http://www.python.org/dev/doc/devel/whatsnew/node8.html
>
> 2) source code:
> http://www.lysator.liu.se/~astrand/popen5/
>
> 3) Windows builds (pre Python-2.4):
> http://effbot.org/downloads/#subprocess
>
> Regards
>
> Carl

Thanks for the links. I hope someone writes some examples soon! ;)

Stephen
--
http://mail.python.org/mailman/listinfo/python-list


jeff at ccvcorp

Oct 19, 2004, 5:48 PM

Post #4 of 5 (785 views)
Permalink
Re: popen and two-way communication [In reply to]

cmkl wrote:

>You may be interested in the new subprocess module:
>
>1) PEP:
> http://www.python.org/dev/doc/devel/whatsnew/node8.html
>
>2) source code:
> http://www.lysator.liu.se/~astrand/popen5/
>
>3) Windows builds (pre Python-2.4):
> http://effbot.org/downloads/#subprocess
>

This looks nice, but I suspect that it won't help the O.P.

Admittedly, I haven't tested subprocess. But interacting with SSH or
gpg or most other password-requesting programs doesn't work properly
through pipes. These programs read directly from the controlling TTY,
rather than from stdin. Pipes don't affect the controlling TTY, meaning
that you'll *still* be prompted for the password.

In short, some version of (or replacement for) Expect is probably still
needed. It is indeed too bad that pexpect won't work on Windows, or
more accurately that the pty which pexpect relies on doesn't work on
Windows... (Fortunately for me, I need to run ssh on Linux, so pexpect
should serve my purposes just fine.)

Jeff Shannon
Technician/Programmer
Credit International

--
http://mail.python.org/mailman/listinfo/python-list


cmkleffner at gmx

Oct 20, 2004, 12:08 AM

Post #5 of 5 (781 views)
Permalink
Re: popen and two-way communication [In reply to]

Expect-like functionality is not supported with subprocess.py
says the PEP. However, Cygwin Python is supported by pexpect AFAIK.
See http://pexpect.sourceforge.net/

Regards

Carl

Jeff Shannon <jeff [at] ccvcorp> wrote in message news:<10nbdakhv1indf2 [at] corp>...
>
> Admittedly, I haven't tested subprocess. But interacting with SSH or
> gpg or most other password-requesting programs doesn't work properly
> through pipes. These programs read directly from the controlling TTY,
> rather than from stdin. Pipes don't affect the controlling TTY, meaning
> that you'll *still* be prompted for the password.
>
> In short, some version of (or replacement for) Expect is probably still
> needed. It is indeed too bad that pexpect won't work on Windows, or
> more accurately that the pty which pexpect relies on doesn't work on
> Windows... (Fortunately for me, I need to run ssh on Linux, so pexpect
> should serve my purposes just fine.)
>
> Jeff Shannon
> Technician/Programmer
> Credit International
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.