Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9190221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:24:44+00:00 2026-06-17T20:24:44+00:00

So I’m writing a shell in Python, and the filename is jsh.py . When

  • 0

So I’m writing a shell in Python, and the filename is jsh.py. When I run the code, it doesn’t work for some reason. A window pops up but closes immediately. What is worng with my code?

import os
import random
import time
import path
import string
import sys

commandAvail = 'ls where chdir mk mkdir cp mv rm rmdir view ext shutdown edit unix dos man-all man-unix man-dos'
commandAvailUnix = 'exec permission group'
commandAvailDos = ' '
print('Welcome to jsh alpha 1!')
commandPlatform = input('System: (UNIX/DOS):')
commandLine()

def commandLine():
        while 1 == 1:
                command = input('$ ')
                if command in commandAvail:
                        if command.startswith('ls'):
                                commandKeyword = 'ls'
                                commandOptions = command - commandKeyword
                                ls(commandOptions)
                        elif command.startswith('where'):
                                commandKeyword = 'where'
                                commandOptions = command - commandKeyword
                                where()
                        elif command.startswith('chdir'):
                                commandKeyword = 'chdir'
                                commandOptions = command - commandKeyword
                                chdir()
                        elif command.startswith('mk'):
                                commandKeyword = 'mk'
                                commandOptions = command - commandKeyword
                                mk()
                        elif command.startswith('mkdir'):
                                commandKeyword = 'mkdir'
                                commandOptions = command - commandKeyword
                                mkdir()
                        elif command.startswith('cp'):
                                commandKeyword = 'cp'
                                commandOptions = command - commandKeyword
                                cp()
                        elif command.startswith('mv'):
                                commandKeyword = 'mv'
                                commandOptions = command - commandKeyword
                                mv()
                        elif command.startswith('rm'):
                                commandKeyword = 'rm'
                                commandOptions = command - commandKeyword
                                rm()
                        elif command.startswith('rmdir'):
                                commandKeyword = 'rmdir'
                                commandOptions = command - commandKeyword
                                rm()
                        elif command.startswith('view'):
                                commandKeyword = 'view'
                                commandOptions = command - commandKeyword
                                rm()
                        elif command.startswith('edit'):
                                commandKeyword = 'edit'
                                commandOptions = command - commandKeyword
                                edit()
                        elif command == 'man-all':
                                print('Commands that work for all underlying platforms:')
                                print(commandAvail)
                        elif command == 'man-unix':
                                print('Commands that only work on Unix systems:')
                                print(commandAvailUnix)
                        elif command == 'man-dos'
                                print('Commands that only work on DOS systems:')
                                print(commandAvailDos)
                        elif command.startswith('unix'):
                                commandType = 'unix'
                                unix()
                        elif command.startswith('dos'):
                                commandType = 'dos'
                                dos()
                        elif command.startswith('ext'):
                                commandKeyword = 'ext'
                                commandOptions = command - commandKeyword
                                ext()
                        elif command == 'shutdown':
                                sys.quit(0)
                        else:
                                print('jsh has experienced an internal error and has to shutdown.')
                                sys.quit(10)
                else:
                        print('Command \'' + command + '\' not recognized as internal or external.')

def ls(options):
        if commandPlatform == 'UNIX':
                os.system('ls' + options)
        else:
                os.system('dir' + options)
        commandLine()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:24:45+00:00Added an answer on June 17, 2026 at 8:24 pm

    You forgot to put ‘:’ after elif command == ‘man-dos’

    Just run: python3 yourscript for debugging purposes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I am writing an app for my school newspaper, which is run completely online
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.