Grokbase Groups Python sapug May 2010
FAQ
Hello

In python 2.5, ubuntu 8.04, how can I get a variable to work, instead of
having to use a string literal, in the following?

I want to do

subprocess.call('scanimage -args- > ${outfile}', shell = True)

but I can only do

subprocess.call('scanimage -args- > /home/garry/Desktop/junk', shell =
True)

Everything on the web I've seen is a string literal, not a variable,
except one instance of $HOME, which kinda doesn't count, because the
variable already existed before.

I've fiddled for 5 hours, time to ask for help.

Anybody know how do do this?
------------------------------------
Garry Trethewey
------------------------------------

Search Discussions

  • Daryl Tester at May 25, 2010 at 8:17 am

    Garry Trethewey wrote:

    subprocess.call('scanimage -args- > ${outfile}', shell = True)

    but I can only do

    subprocess.call('scanimage -args- > /home/garry/Desktop/junk', shell =
    True)
    This is just standard string substitution (see 3.6.2 "String Formatting
    Operations <http://docs.python.org/release/2.5.2/lib/typesseq-strings.html>).

    You might use (given outfile = '/some/path'):

    subprocess.call('scanimage -args- > %s' % outfile, shell = True)

    Or are you actually trying to retrieve $HOME?


    --
    Regards,
    Daryl Tester

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupsapug @
categoriespython
postedMay 25, '10 at 4:39a
activeMay 25, '10 at 8:17a
posts2
users2
websitepython.org

2 users in discussion

Daryl Tester: 1 post Garry Trethewey: 1 post

People

Translate

site design / logo © 2018 Grokbase