![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Hobbyist Programmer
Join Date: Jul 2004
Location: Location
Posts: 138
Rep Power: 5
![]() |
Python shell help
Hi everyone,
For the fun of it, I am trying to write a shell program similar to Linux's bash or Windows' command. I'm writing the program on Windows, and this is what I have so far: import os
os.chdir('/') #Change the directory to Windows root
while True:
directory = os.path.abspath(os.curdir)
directory += '>>'
prompt = raw_input(directory) #Print the command line prompt as C:\>>So far, it waits for the user's input by looping C:\>>. My next step is to actually make the shell respond to user commands. For example, if the user inputs put "Text here" the shell will interpret the statement as print "Text here". I think the best thing to use is a parser or string methods. The problem is that I haven't found many docs on either item, and am not sure how to implement this. Does anyone here have a tutorial or an example on how I would parse text so that python can interpret it and do what I want? (I also want to do things such as change directory with a command like dir <dir here> and so on.) Thanks |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [tutorial] Python for programming beginners | coldDeath | Python | 30 | Dec 14th, 2005 11:35 AM |
| Convert Python script to C++ code | clanotheduck | Python | 17 | Sep 25th, 2005 8:55 AM |
| Advanced Python Tricks | Arevos | Python | 19 | Sep 24th, 2005 7:39 AM |
| Hybrid python shell | Arevos | Existing Project Development | 0 | Sep 22nd, 2005 4:37 PM |
| Python - A Programmers Introduction | coldDeath | Python | 17 | Aug 19th, 2005 12:41 PM |