Reputation: 5972
I wrote a bash that has python command included in loop: (part of script)
#!/bin/bash
ARG=( $(echo "${@:3}"))
for (( i=1; i<=$#-3; i++ ))
do
python -c "print('<Command with variables>' * 1)"
done
When I run it, depends on number of my args for example I have this output:
nohup command-a &
nohup command-b &
nohup command-c &
How do I execute the output lines from bash immediately?
Can I tell python command to run them in each iteration? How?
Thank you
Upvotes: 0
Views: 165
Reputation: 2127
You can achieve that by executing the python code in a sub-shell and evaluating the content of that shell afterwards.
eval $(python -c ...)
$()
returns a string you can evaluate with eval
Upvotes: 1
Reputation: 242113
You are asking two questions. I can only answer the first one:
If you want to run commands coming to the standard output, just redirect them to bash:
python -c 'print "ls"' | bash
Upvotes: 0