I want to start a command in command prompt, but os.system() can only do one command, and I want it to start from a url.
Example:

import os,getpass
print "Altline (C) James Lu"
print "All rights reserverd."
def currentuser():
    try:
        return "Users/" + getpass.getuser()
    except:
        print "Cannot detect user, starting from drive."
        return ""
try:
    os.path.isdir("C:/")
except:
    p = raw_input("C drive does not exist, please input drive:")+":/"+ currentuser()
else:
    p = "C:/" + currentuser()
while True:
    prompt = p+">"
    c = raw_input(prompt)
    if c.startswith("to"):
        u = c.lstrip("to ")
        if os.path.exists(os.path.join(p,u)):
            p = os.path.realpath(os.path.join(p,u))
        else:
            print "No such directory/file"
    elif c.startswith("goto"):
        if os.path.exists(u):
            p = os.path.realpath(u)
        else:
            print "No such directory/file"

    else:
        print os.system(c) 

Note: I am doing this because there is something crazy wrong with starting it, so you can't just start it up directly.

I'm not really clear what you're trying to do but os.system has fallen from favor and the subprocess module is recommended. Maybe that will suit your needs better.

commented: WRONG! os.system for all the commands in command line! not for launching programs! +0
commented: indeed +14

WRONG! os.system for all the commands in command line!
not for launching programs!

How would you phrase the command line if you had to launch the program from a terminal ? This is the command line to use for your call. Also rrashkin is right in recommending the subprocess module. I recommend my snippet to run the command in a comfortable way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.