I have a shell script which runs a python program which has its own parameters:
#!/bin/bash
python blah.py var1 var2
./run key
I need to find a way to retrieve the contents of key from the python program. I have tried just making the python program return the value, and then doing :
key=python blah.py var1 var2
in my shell script, but that didn't work because it stated key was "outside the function".
Thanks in advance
Use this
Another alternative to modifying the python script to output the value of the
key
variable is to modify the python script to call therun
programOne liner demo:
(ok, so it's two lines)
You can do:
The
$( )
syntax opens a subshell, and runs the command. The stdout output is then dumped in its place