2

I have a python script which requires a value from a shell script.

Following is the shell script (a.sh):

#!/bin/bash
return_value(){
  value=$(///some unix command)
  echo "$value"
}

return_value

Following is the python script:

Import subprocess
answer = Subprocess.call([‘./a.sh’])
print("the answer is %s % answer")

But its not working.The error is:

ImportError : No module named subprocess

I guess my verison (Python 2.3.4) is pretty old. Is there any substitute for subprocess that can be applied in this case??

1 Answer 1

4

Try commands module for py2.3.4, note that this module has been deprecated since py2.6:

Use commands.getoutput:

import commands
answer = commands.getoutput('./a.sh')
Sign up to request clarification or add additional context in comments.

1 Comment

It worked !!!! How do you think of this? I know our team needs to update our python version but Thanks a lot !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.