Hi all,
I need help to create a script that will open a terminal screen with command options.
Example.
1) execute script.py
This will open in the same terminal something like this
########Open Termianl#####################
# selection your options #
##########################################
Press A for ping
Press B for SSH
When I press in my keyboard A it will call a script call ping.
Thanks for any help.
What have you tried?
Post your attempt in Python code tags, along with questions and/or errors you get in error tags.
Sorry for my bad post, im working with what I need is to work with Menus. I have this point, but the what I looking is when I press 1 this will run a script but when the script finishes I want it to go back to the main menu and not to stay in the linux prompt.
## Text menu in Python
def print_menu(): ## Your menu design here
print 30 * "-" , "CLI SYSTEM" , 30 * "-"
print "1. Test SSH Connection (check ssh to all hosts)"
print "2. Backup (backup all device in host /tmp)"
print "3. Startup Provisioning"
print "4. Update Provisioning"
print "5. Troublshooting"
print "6. Exit"
print 67 * "-"
loop=True
while loop: ## While loop which will keep going until loop = False
print_menu() ## Displays menu
choice = input("Enter your choice [1-6]: ")
if choice==1:
print "Menu 1 has been selected"
## You can add your code or functions here
elif choice==2:
print "Menu 2 has been selected"
## You can add your code or functions here
elif choice==3:
print "Menu 3 has been selected"
## You can add your code or functions here
elif choice==4:
print "Menu 4 has been selected"
## You can add your code or functions here
elif choice==5:
print "Menu 5 has been selected"
## You can add your code or function here
elif choice==6:
print "Menu 6 has been selected"
## You can add your code or functions here
loop=False # This will make the while loop to end as not value of loop is set to False
else:
# Any integer inputs other than values 1-6 we print an error message
raw_input("Wrong option selection. Enter any key to try again..")