I have a shell script in my JSON document jsonStr
which I am able to execute it using Python subprocess module and it works fine.
Below is my Python script which works fine if I execute the shell script without passing anything -
import subprocess
import json
testing = "HelloWorld"
jsonStr = '{"script":"#!/bin/bash \\n STRING=\'Hello World\' \\n echo $STRING \\n"}'
j = json.loads(jsonStr)
print "start"
subprocess.call(j['script'], shell=True)
print "end"
Now is there any way to pass a variable value to my shell script in the json document from the Python script? Meaning I need to pass testing
value to my shell script and then print out from the shell script the value of testing
after getting executed from the subprocess module.
Is this possible to do?