How to get into python environment and run some python commands and return to normal terminal using shell script
0
votes
2
answers
6445
views
Sorry about the title it may not be clear. Here is the complete explanation of my doubt. I am writing the below shell script and expecting the mentioned output.
#!/bin/bash
python3
print("Hello World")
exit()
echo "The execution is completed"
The output what i am expecting is, it should enter the python3 interpreter and execute the
print
and exit()
commands and after executing the exit()
command as the interpreter exits if we do it manually and then execute the echo
command.But it is not working that way, after executing python3
it is entering the python3 interpreter but not executing the print
and exit()
.
>>>
It is entering the python3 correctly and then stops there till i manually exit the python interpreter.
What changes should i make in order to get my expected output.
1. The follow up question: Is it possible to get the output Hello world
or any other output that is generated in the python interpreter to bash environment and use it in the bash script.
2.And method which you specify to run the python commands will that work for other tools as well?
Asked by Rakesh Nara 10
(62 rep)
Sep 18, 2020, 07:04 PM
Last activity: Sep 23, 2020, 03:03 PM
Last activity: Sep 23, 2020, 03:03 PM