0

I'm new to Python and have been able to find answers to most of my questions here so I thought you guys could help me with this one:

I'm developing somewhat of a hybrid application using bash scripts to show menus and to call python applications (I'm doing it this way to simplify things).

My problem is that when I end the python application, it simply terminates the process and to go back to the menus, I have to start the whole program again. I tried using "subprocess.call('xxx')" but it opens the bash scrips inside of the application I am running and shows text (echo) only, no other functions.

Is there a way to end the python application first and then call the shell script?

2
  • 2
    "When I end the python application, it simply terminates the process and to go back to the menus, I have to start the whole program again." What you should do is embed the call to the python program in a loop (in your bash script). Also, why can't you just code the menu in Python? Commented Nov 15, 2015 at 2:07
  • @4ae1e1 yes, that worked like a charm! Thank you! :) And to be honest, because I had already made all of them using bash and converting it to python would've taken a lot of time... I'm only using python for database operations, everything else on the "application" is bash. Commented Nov 15, 2015 at 16:05

1 Answer 1

1

You can wrap your code in a while-true loop

while :; do
    # Assuming you want to show the menu before you start a program:
    bash showMenu.py
    python myScript.py
    # When the above scripts exits the process will start all over again
    # You might want to consider checking the exit code and only continue if the program exits with status code 0
    # [ $? gt 0 ] && break
done
Sign up to request clarification or add additional context in comments.

3 Comments

I actually used "wait" in my bash script as suggested by 4ae1e1, because it seemed easier to do it this way... But thank you for your answer! :-)
I didn't suggest wait anywhere in my comment... My answer would have been the same as this one.
@4ae1e1 You will need to use @user to inform John about your comment :-) If you dont it will go to the OP of the post (me in this case)

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.