Expect script problem

f t
2010-06-22
2013-05-02
  • f t
    f t
    2010-06-22

    I have a Python script calling a shellscript which in turn calls an expect script.  The Python script calls the shellscript using subprocess popen and passes a value thru stdin.  The shellscript reads the value and passes it along to the expect script.
    I am spawning mysql in the expect script.  If I run the Python program, the expect script fails.  Whereas if I run the shellscript
    from the command line, then I see the mysql prompt. 
    I would appreciate any help in figuring out where the problem is.
    I have included all the 3 scripts here for reference.

    Thanks.

    Python script with subprocess

    import subprocess
    print '\n===================In dummy.py=========================='
    proc = subprocess.Popen(,
                             shell=True,executable='/bin/bash',
                            stdin=subprocess.PIPE,
                            )
    proc.communicate('pass')

    Shellscript

    #!/bin/bash
    read pass
    echo "-------------In shell script : $pass ---------"
    ./exp $pass

    Expect

    #!/usr/bin/expect
    set mypass
    set mypass
    puts "====inexp=======$mypass================"

    spawn mysql -uroot -p
    #######################
    expect "Enter password: "
        send "pass\r"
    interact
    ===================================================================