Results 1 to 5 of 5

Thread: Special String Manipulation (Python)

  1. #1
    Join Date
    Sep 2007
    Beans
    400
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Special String Manipulation (Python)

    Python (in my opinion) has some pretty funky string manipulation, and I love it.
    However, say:
    Code:
    a = raw_input("Xact FilePath: ")
    os.system("shred #where 'a' would go# -f -u -v -x -z")
    How do I get the filepath (the str 'a') to pop up in the os.system call??
    Last edited by 1337455 10534; November 9th, 2007 at 03:11 AM.

  2. #2
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    Re: Special String Manipulation (Python)

    Code:
    os.system("shred #where '%s' would go# -f -u -v -x -z" % a)
    For multiple values, it takes tuples after %.
    LambdaGrok. | #ubuntu-programming on FreeNode

  3. #3
    Join Date
    Sep 2007
    Beans
    400
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: Special String Manipulation (Python)

    but a is just one value...
    so:
    Code:
    #!/usr/bin/env python
    import os, time
    print "DETH SHRED"
    a = raw_input("Xact FilePath: ")
    os.system("sudo shred %s -f -u -v -x -z" % a)
    b = input("Verify Deth? (Recursive Destruction of Directories as Well) [1:Y, 2:N]: ")
    if b == 1:
           os.system("sudo rm -r -f -d -v %s" % a)
           time.sleep(3)
    elif b == 2:
           print "Pwn3d."
    Excellent.
    Last edited by 1337455 10534; November 10th, 2007 at 02:18 AM.

  4. #4
    Join Date
    Sep 2007
    Beans
    400
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: Special String Manipulation (Python)

    Wow. I put that in, it works brilliantly!
    Move on to the GUI!!
    Is EasyGUI easy? - {Seems retarded, but, I need to know}

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

    Re: Special String Manipulation (Python)

    Yes, EasyGUI is easy. It is not really a complete GUI toolkit, but it is an easy way to do things with a GUI. You can visit my wiki for links on learning and getting it.

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
  •