Grokbase Groups Python tutor May 2005
FAQ
Hi,
I am working on getting comfortable with Python, and am trying to rewrite
some of my old (clumsy) bash scripts into python.

I am having a little problem with how to pipe a variable's contents to an
external command. Essentially, I have a variable that contains the
contents of a variable that I want to feed to a series of external commands
(clamav and spamassassin).

EMAIL contains the full email message, and CLAMAV contains the path to the
clamscan bin (and necessary flags). I have tested this on the command line
and it works (so I know the command syntax is correct), but in my python
script it is clear that nothing is getting piped to the scanner.

CLAMAV_h= os.popen(CLAMAV, 'w')
CLAMAV_h.write(EMAIL)
CLAM_RESULT=CLAMAV_h.close()
print CLAM_RESULT

I can make this work by writing to a temp file and scanning that, but I
would like to avoid having to write to and read from a temp file at every
step. I expect I am making a very basic error, stemming from my tackling a
(perhaps?) more advanced problem at this early stage. But one can only get
so far with "Hello World"....

Many thanks,

Jeff


* * * * * * *
Jeffrey Rice || jeffrice at finity.org || www.finity.org

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 5 | next ›
Discussion Overview
grouptutor @
categoriespython
postedMay 12, '05 at 4:39a
activeMay 16, '05 at 12:18a
posts5
users2
websitepython.org

2 users in discussion

Jeffrey Rice: 3 posts Danny Yoo: 2 posts

People

Translate

site design / logo © 2022 Grokbase