Python subprocess problem

Discussion in 'Software' started by bmt, Jun 14, 2010.

  1. bmt

    bmt

    Joined:
    Jun 14, 2010
    Messages:
    1
    Hi,

    Apologize if I am in the wrong forum

    I believe I am having problems with Python subprocess popen.
    I have a python script in which I use subprocess.popen to call a bash script.
    The bash script in turn calls an expect script. If I run the bash script directly on the command line, it works.
    However, when I run the python program, it fails.
    Any help/input is really appreciated.
    Here are the 3 scripts.
    ================================================== ======
    Python scriptlet
    ================
    import subprocess
    print '\n===================In dummy.py=========================='
    proc = subprocess.Popen(['./exp.sh'],
    shell=True, executable="/bin/bash",
    stdin=subprocess.PIPE
    )
    proc.stdin.write('pass\n')

    Shell script invoked by the above Python scriptlet
    ==================================================
    #!/bin/bash
    read pass
    echo "In shell script : $pass --------------"
    ./exp $pass

    Expect script invoked by the above shell script
    ===============================================
    #!/usr/bin/expect
    set pass [lindex $argv 0]
    set pass [string trim $pass]
    puts "====inexp=======$pass================"

    spawn mysql -uroot -p
    expect password
    send "$pass\r"
    interact
    ================================================== ======
    Thanks.
    bmt, Jun 14, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?iso-8859-1?Q?Frisbee=AE?=

    OT: Which Monty Python Character Are You?

    =?iso-8859-1?Q?Frisbee=AE?=, May 24, 2004, in forum: MCSE
    Replies:
    9
    Views:
    583
  2. =?Utf-8?B?U2FuZHdvcm0=?=

    Name that Python!!!! Yes, you too could win!!!

    =?Utf-8?B?U2FuZHdvcm0=?=, Jun 9, 2004, in forum: MCSE
    Replies:
    16
    Views:
    561
    =?Utf-8?B?U2FuZHdvcm0=?=
    Jun 10, 2004
  3. English Teacher

    GOOD BOOK for PYTHON/Linux

    English Teacher, Oct 21, 2003, in forum: Digital Photography
    Replies:
    1
    Views:
    357
    Mark Herring
    Oct 21, 2003
  4. Mswed
    Replies:
    1
    Views:
    1,057
    Mswed
    Jul 29, 2008
  5. partyin
    Replies:
    0
    Views:
    1,015
    partyin
    Feb 21, 2012
Loading...

Share This Page