Last active
December 23, 2015 08:29
-
-
Save imryan/6608306 to your computer and use it in GitHub Desktop.
Used at my school to execute shell scripts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 2 Shell Executor | |
# September 18, 2013 | |
# Ryan Cohen | |
import socket, sys | |
from subprocess import call | |
def main(): | |
print "\nPython 2 Shell Executor" | |
ip = socket.gethostbyname(socket.gethostname()) | |
print "Your internal IP:", ip, "\n" | |
print "[1] Execute Command\n[2] Exit" | |
choice = raw_input("\n> ") | |
if choice is "1": | |
get_input() | |
elif choice is "2": | |
sys.exit() | |
else: | |
main() | |
def get_input(): | |
command_name = raw_input("\ncommand_name> ") | |
command_args = raw_input("command_args> ") | |
if not command_args: | |
call(command_name, shell = True) | |
main() | |
else: | |
call([command_name, command_args]) | |
main() | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 3 Shell Executor | |
# September 18, 2013 | |
# Ryan Cohen | |
import socket, sys | |
from subprocess import call | |
def main(): | |
print("\nPython 3 Shell Executor") | |
ip = socket.gethostbyname(socket.gethostname()) | |
print("Your internal IP:", ip, "\n") | |
print("[1] Execute Command\n[2] Exit") | |
choice = input("\nchoice> ") | |
if choice is "1": | |
get_input() | |
elif choice is "2": | |
sys.exit() | |
else: | |
main() | |
def get_input(): | |
command_name = input("command_name> ") | |
command_args = input("command_args> ") | |
if not command_args: | |
call(command_name, shell = True) | |
main() | |
else: | |
call([command_name, command_args]) | |
main() | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment