Fixing Ant build that fails due to space in path

Discussion in 'Java' started by eran, Aug 5, 2008.

  1. eran

    eran Guest

    Hi,

    I’m trying to run an installation that uses Ant. The installation has
    to update some files that are in an existing folder. The folder is
    supposed to be assigned to a certain environment variable, which the
    Ant script relies on. The problem is this: the folder contains a space
    (program files...), and that breaks the installation.

    The script is along the line of:
    <exec dir="${AS_HOME}/bin" executable="cmd.exe" ... >
    where AS_HOME contains the space. I’m not sure this exact command
    fails, as there are others in the build.xml as well, but they all look
    similar. I tried to wrap the path in the env. variable with quotes, to
    no avail. I don’t mind changing the XML to a fixed path, but obviously
    using more quotes above will do more harm than good.

    I’m not familiar with Ant, and I don’t have the time to learn how to
    use it properly. I just need this problem to be solved. Can anyone
    tell me how can I make it work with spaces in the given path?
     
    eran, Aug 5, 2008
    #1
    1. Advertising

  2. eran schrieb:
    > The script is along the line of:
    > <exec dir="${AS_HOME}/bin" executable="cmd.exe" ... >
    > where AS_HOME contains the space. I’m not sure this exact command

    [ ... ]
    > I’m not familiar with Ant, and I don’t have the time to learn how to
    > use it properly. I just need this problem to be solved. Can anyone
    > tell me how can I make it work with spaces in the given path?


    the usual solution for probs withs spaces in path is =

    "'...'" ,means try

    <exec dir="'${AS_HOME}/bin'" executable="cmd.exe" ... >

    if you're not sure, whether your property has spaces or not,
    simply put it between those extra '...' and you're done.


    Regards, Gilbert
     
    Gilbert Rebhan, Aug 5, 2008
    #2
    1. Advertising

  3. eran

    Lew Guest

    eran wrote:
    > Anyway, I eventually found a simple solution: I mapped the folder as a
    > network drive, and that made the path much shorter, and without any
    > spaces. So instead of "C:\program files\xyz" [sic], I was able to work with
    > "F:\xyz".


    or "C:\PROGRA~1\xyz"

    --
    Lew


    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    [Zionism, fascism, ethnic cleansing, terrorism, war crimes, Khasars,
    Illuminati, NWO]

    "The epithet "anti-Semitism" is hurled to silence anyone,
    even other Jews, brave enough to decry Israel's systematic,
    decades-long pogrom against the Palestinian Arabs.

    Because of the Holocaust, "anti-Semitism" is such a powerful
    instrument of emotional blackmail that it effectively pre-empts
    rational discussion of Israel and its conduct.

    It is for this reason that many good people can witness
    daily evidence of Israeli inhumanity toward the "Palestinians'
    collective punishment," destruction of olive groves,
    routine harassment, judicial prejudice, denial of medical services,
    assassinations, torture, apartheid-based segregation, etc. --
    yet not denounce it for fear of being branded "anti-Semitic."

    To be free to acknowledge Zionism's racist nature, therefore,
    one must debunk the calumny of "anti-Semitism."

    Once this is done, not only will the criminality of Israel be
    undeniable, but Israel, itself, will be shown to be the
    embodiment of the very anti-Semitism it purports to condemn."

    --- Greg Felton,
    Israel: A monument to anti-Semitism
     
    Lew, Aug 7, 2008
    #3
  4. eran

    eran Guest

    Thanks, Gilbert, but that didn't work. I can't say I payed a lot of
    attention to the way I tried to use your solution - just wrapped the
    path everywhere with the apostrophe.

    Anyway, I eventually found a simple solution: I mapped the folder as a
    network drive, and that made the path much shorter, and without any
    spaces. So instead of "C:\program files\xyz", I was able to work with
    "F:\xyz".
     
    eran, Aug 7, 2008
    #4
  5. eran schrieb:
    > Thanks, Gilbert, but that didn't work. I can't say I payed a lot of
    > attention to the way I tried to use your solution - just wrapped the
    > path everywhere with the apostrophe.


    > Anyway, I eventually found a simple solution: I mapped the folder as a
    > network drive, and that made the path much shorter, and without any
    > spaces. So instead of "C:\program files\xyz", I was able to work with
    > "F:\xyz"


    OK, good you found a solution.

    I had several occasions where the "'...'" hack worked for me (f.e.
    cvs modulenames with spaces, or path with spaces) but maybe it
    doesn't work always.

    But remember - like Lew also said in this thread - NEVER use a path
    with spaces in it if possible,thank you Bill for
    "Documents and Settings , Dokumente und Einstellungen ;-)


    Regards, Gilbert
     
    Gilbert Rebhan, Aug 8, 2008
    #5
  6. eran

    Lew Guest

    Gilbert Rebhanwrote:
    > I had several occasions where the "'...'" hack worked for me (f.e.


    That's not a hack, that's how you include "special" but legal
    characters.

    > cvs modulenames with spaces, or path with spaces) but maybe it
    > doesn't work always.
    >
    > But remember - like Lew also said in this thread - NEVER use a path
    > with spaces in it if possible,


    I never said that. Do not misquote me.

    I did say that it is weird to put things under "Program Files/", but
    that isn't because of the space, it's because "Program Files/" is for,
    well, program files, not development files.

    I find no problem using paths with spaces in them. I do not recommend
    avoiding them. I did say to think about how to use quote marks, and
    not to use them randomly in ignorance.

    --
    Lew
     
    Lew, Aug 8, 2008
    #6
  7. Lew schrieb:
    > Gilbert Rebhanwrote:
    >> I had several occasions where the "'...'" hack worked for me (f.e.

    >
    > That's not a hack, that's how you include "special" but legal
    > characters.


    I call it a 'hack' because normally i do not need such
    special treatment, apart from xml entities (quot,amp,lt,gt ....)
    sometimes or putting stuff between <![CDATA[ ... ]]>
    as ant scripts are xmlfiles.

    > I never said that. Do not misquote me.
    > I did say that it is weird to put things under "Program Files/", but
    > that isn't because of the space ...


    Ok, seems i got you wrong

    > ... it's because "Program Files/" is for,
    > well, program files, not development files.


    +1, I used to have an own partition on windows
    for system only, another for documents and settings, another
    for projects only ..., Separating stuff or using a standard
    project layout = /src, /bin, /dist , /libs, /doc ... is another
    story

    > I find no problem using paths with spaces in them. I do not recommend
    > avoiding them.


    I recommend to avoid them, as they are often a source of trouble.
    A space in a filename /pathname maybe legal, but there's a bunch
    of programs and libraries that do not handle legal filenames.
    I would not recommend using german umlauts for path or
    filenames either, even if they are allowed.

    I did say to think about how to use quote marks, and
    > not to use them randomly in ignorance.


    I did not say to use quote marks randomly but
    "...'path/with spaces in it/' ..."

    Using the 8.3 equivalent name you get via dir /x ...

    C:\>dir /x
    ....

    01.11.2007 13:45 <DIR> DOKUME~1 Dokumente und Einstellungen
    07.06.2008 21:03 <DIR> ghc
    01.11.2007 14:04 <DIR> POSTIN~1 Postinstall
    15.06.2008 13:45 <DIR> PROGRA~1 Programme
    13.02.2008 10:29 <DIR> ruby
    15.07.2008 21:03 <DIR> totalcmd
    28.05.2008 21:53 <DIR> WINXP

    .... maybe a solution too, but why not simply using pathnames
    without spaces or spaces replaced with '_' instead.
    Makes life so much easier IMO


    Regards, Gilbert
     
    Gilbert Rebhan, Aug 8, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shuo Xiang

    Stack space, global space, heap space

    Shuo Xiang, Jul 9, 2003, in forum: C Programming
    Replies:
    10
    Views:
    2,937
    Bryan Bullard
    Jul 11, 2003
  2. Christian Seberino
    Replies:
    21
    Views:
    1,719
    Stephen Horne
    Oct 27, 2003
  3. Ian Bicking
    Replies:
    2
    Views:
    1,055
    Steve Lamb
    Oct 23, 2003
  4. Ian Bicking
    Replies:
    2
    Views:
    750
    Michael Hudson
    Oct 24, 2003
  5. Fresh
    Replies:
    2
    Views:
    649
    Bo Persson
    Apr 22, 2008
Loading...

Share This Page