Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > Python subprocess problem

Reply
Thread Tools

Python subprocess problem

 
 
bmt bmt is offline
Junior Member
Join Date: Jun 2010
Posts: 1
 
      06-14-2010
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to import subprocess into my 'subprocess.py' file hiral Python 2 05-05-2010 12:56 PM
subprocess + python-daemon - bug/problem? Andy Clegg Python 4 09-16-2009 09:32 PM
python 2.5 scripting in vim on windows: subprocess problem Dmitry Teslenko Python 1 10-22-2007 03:01 PM
Python wrapper, problem with subprocess read/write NeoGregorian Python 1 09-10-2007 10:31 AM
[Subprocess/Windows] subprocess module under Windows 98 Andreas Jung Python 2 11-02-2005 05:41 PM



Advertisments