Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2005
    Kosice, Slovakia
    Thanked 0 Times in 0 Posts

    passing arguments with ampersands?


    i have a win32 gui application that accepts filenames as arguments (either via command line or via associating an extension to the application) which are then opened in it. the problem is that as soon as the filename contains characters like '&', the process fails at the very beginning (sys.argv).

    for example when the full path of the file im trying to open like this is
    D:\ftp\Music\Mixes & Compilations\Above & Beyond - Essential Mix\001_Essential_Mix_2004-06-06_-_Above_and_Beyond.txt
    when i put 'print sys.argv[1:]' at the very beginning of the script, all i get is this:

    i already have a piece of code that puts together paths with spaces sent via arguments, but this '&' drives me crazy.

    other than that, after i close the application (which actually starts without any errors), the commands line gets filled with a message like this:

    The system cannot find the path specified.
    'Beyond' is not recognized as an internal or external command,
    operable program or batch file.
    any idea how to solve this?
    thanks in advance!
    "Programming is an art form that fights back."

  2. #2
    New Coder
    Join Date
    May 2006
    Thanked 1 Time in 1 Post
    when passing the argument, enclose in double quotes
    python script.py "D:\ftp\Music\Mixes & Compilations\Above & Beyond - Essential Mix\001_Essential_Mix_2004-06-06_-_Above_and_Beyond.txt"

  3. Users who have thanked ghostdog74 for this post:

    SHY (08-27-2007)


Posting Permissions

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