os.system prob

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aaron Barclay

    os.system prob



    Hello,

    I am trying to send some commands via os.system but am getting tripped
    up by it stripping out the quote marks. I have:

    program = "dcop klipper klipper setClipboardCon tents "
    fileOut = '"test = FileOut(0,
    "/bobbleheads/shots/bh112_01/roto_neck/ramin/renders/test", "Auto");"'

    The fileOut string must be enclosed with "'s and also contains several "'s.

    So I put them togeter

    command = program + fileOut
    os.system(comma nd)

    My clipboard then contains

    test = FileOut(0,
    /bobbleheads/shots/bh112_01/roto_neck/ramin/renders/test, Auto);

    all of the " have been stripped out.

    I need it to contain

    "test = FileOut(0,
    "/bobbleheads/shots/bh112_01/roto_neck/ramin/renders/test", "Auto");"

    any ideas??

    ps - this may only work under KDE. If there are python specific commands
    to put things in the clip board
    I can't find them??


    Thanks in advance.

  • Donn Cave

    #2
    Re: os.system prob

    In article <mailman.1412.1 092079959.5135. python-list@python.org >,
    Aaron Barclay <aaronb@jhcs.co .uk> wrote:
    [color=blue]
    > I am trying to send some commands via os.system but am getting tripped
    > up by it stripping out the quote marks. I have:[/color]

    Quoting can be tricky, when you have multiple layers of
    interpretation - python, shell, etc. You can probably
    figure it out with some experimentation , but if possible
    it's better to avoid the problem. Use os.spawnv - like,

    os.spawnv(os.P_ WAIT, '/usr/local/bin/whatever',
    ['whatever', 'parameter one'])

    This invokes the command directly, so there's no shell
    command line parsing.

    Donn Cave, donn@u.washingt on.edu

    Comment

    Working...