Python Forum
Small command shell
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Small command shell
Hi there! Got code! Down here |
import os
print("mini command line v1.0.0")
print("type help for a list of commands.")

def commandline():
    commandline = input("C:\\system\\commands>")
    return commandline

commands = ["help", "dir", "exit"]

commandline_string = ""
while commandline_string != "exit":
    commandline_string = commandline()

    if not commandline_string in commands and commandline_string != "":
        print("Unable to run command. Please check that the command exists and that you have permission to use it.")

    if commandline_string == "help":
        print("These are the valid commands")
        for command in commands:

    elif commandline_string == "dir":
        files = os.listdir("/")
        for file in files:

    elif commandline_string == "dir /?":
        print("the dir command will display your computer directories.")

    elif commandline_string == "exit /?":
        print("the exit command will exit the XC command line command interpreter.")
That is the code for a mini command line. I did not know how to add files so...
Larz60+ write Mar-30-2021, 08:25 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Fixed for you this time. Please use bbcode tags on future posts.
If you mouse over the tool bar icons it's the blue and yellow one, when you hoover over it it says "insert python". Put your code between the tags please
Thanks for the help. I will do that next time.

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020