diff --git a/shell.py b/shell.py index 776f7d2..50cd85a 100644 --- a/shell.py +++ b/shell.py @@ -1,24 +1,18 @@ -# Import Modules import os import subprocess import psutil import platform import socket -# Get System Information RAM = psutil.virtual_memory() CPU = platform.processor() OS = os_name = platform.system() -# Shell Version VER = "PCLISH v0.0.4a" -# Configuration PROMPT = "shell@localhost" -# Command Interpretation -- This is the core of the shell def execute_command(command): - # execute commands and handle piping# try: if "|" in command: s_in, s_out = (0, 0) @@ -54,20 +48,16 @@ def execute_command(command): print("pclish: command not found: {}".format(command)) -# Commands - Commands are defined here. def pclish_cd(path): - # convert to absolute path and change directory# try: os.chdir(os.path.abspath(path)) except Exception: print("cd: no such file or directory: {}".format(path)) -def pclish_echo(): - txt = input("What would you like to echo?:\n") +def pclish_echo(txt): print(txt) -def pclish_oscmd(): - ARGS = input("What OS command would you like to run") +def pclish_oscmd(ARGS): os.system(ARGS) def pclish_help(): @@ -79,8 +69,7 @@ def pclish_help(): system: shows system information mkdir: creates a directory shtdwnsubsys: shuts down the sub system - - note: you have to type mkdir by its self then it will ask for what you want to name the directory""") + oscmd: allows you to run an OS level command""" def pclish_ls(): print("pclish: this feature is not yet supported") @@ -88,9 +77,7 @@ def pclish_ls(): def pclish_ver(): print(VER) -def pclish_mkdir(): - value = input("What would you like to name this new directory:\n") - dir = value +def pclish_mkdir(dir): os.mkdir(dir) def pclish_system(): @@ -109,7 +96,6 @@ def pclish_shtdwnsubsys(): print("Shutting Down XCU Python Based Shell Env") exit() -# Shell Prompt Customization and step 2 of command interpritation def main(): while True: inp = input(PROMPT)