Update 'shell.py'

This commit is contained in:
JaydenMW 2021-02-16 21:48:31 +01:00
parent 64176b7039
commit 94ff8842fb
1 changed files with 11 additions and 4 deletions

View File

@ -4,7 +4,6 @@ import subprocess
import psutil import psutil
import platform import platform
import socket import socket
import getpass
# Get System Information # Get System Information
RAM = psutil.virtual_memory() RAM = psutil.virtual_memory()
@ -12,7 +11,10 @@ CPU = platform.processor()
OS = os_name = platform.system() OS = os_name = platform.system()
# Shell Version # Shell Version
VER = "PCLISH v0.0.3.8a" VER = "PCLISH v0.0.4a"
# Configuration
PROMPT = "shell@localhost"
# Command Interpretation -- This is the core of the shell # Command Interpretation -- This is the core of the shell
def execute_command(command): def execute_command(command):
@ -64,6 +66,10 @@ def pclish_echo():
txt = input("What would you like to echo?:\n") txt = input("What would you like to echo?:\n")
print(txt) print(txt)
def pclish_oscmd():
ARGS = input("What OS command would you like to run")
os.system(ARGS)
def pclish_help(): def pclish_help():
print("""pclish: here are the commands available print("""pclish: here are the commands available
help: shows this page help: shows this page
@ -106,7 +112,7 @@ def pclish_shtdwnsubsys():
# Shell Prompt Customization and step 2 of command interpritation # Shell Prompt Customization and step 2 of command interpritation
def main(): def main():
while True: while True:
inp = input(user@hostname prefix) inp = input(PROMPT)
if inp == "exit": if inp == "exit":
break break
elif inp[:3] == "cd ": elif inp[:3] == "cd ":
@ -125,10 +131,11 @@ def main():
pclish_system() pclish_system()
elif inp == "echo": elif inp == "echo":
pclish_echo() pclish_echo()
elif inp == "oscmd":
pclish_oscmd()
else: else:
execute_command(inp) execute_command(inp)
# Main # Main
if '__main__' == __name__: if '__main__' == __name__:
main() main()