Results 1 to 4 of 4

Thread: Concatinating two things to do a command with Python

  1. #1
    Join Date
    May 2007
    Location
    USA
    Beans
    129

    Concatinating two things to do a command with Python

    Code:
    #The commands import allows the use of linux commands, making this a frontend program
    import commands
    
    def setup():
    	centDir = raw_input("Where did you install cent, the defualt is ~/Centrifuge >")
    	centDirCommand = "cd " +centDir
    	commands.getoutput(centDirCommand)
    	commands.getoutput('mkdir hi')
    setup()
    Currently it will mkdir in the location of the .py not where I ask it to, being ~/Centrifuge

  2. #2
    Join Date
    Apr 2007
    Beans
    14,781

    Re: Concatinating two things to do a command with Python

    Did you try the OS module?

    http://docs.python.org/lib/os-file-dir.html

    It has these functions.

  3. #3
    Join Date
    May 2007
    Location
    USA
    Beans
    129

    Re: Concatinating two things to do a command with Python

    Thanks! That plus a bit of guess work has solved my problem for now, next how can I return to something after I have finished, instead of closing the application. Example

    def hi()
    print "hi"

    and instead of the application ending it goes to the main menu I made, would I def the menu so I can call it over?

  4. #4
    Join Date
    Apr 2007
    Beans
    14,781

    Re: Concatinating two things to do a command with Python

    Quote Originally Posted by Sayers View Post
    Thanks! That plus a bit of guess work has solved my problem for now, next how can I return to something after I have finished, instead of closing the application. Example

    def hi()
    print "hi"

    and instead of the application ending it goes to the main menu I made, would I def the menu so I can call it over?
    Use a loop, and use "if"s and "break"s.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •