• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
  • salvin francis
  • Frits Walraven
  • Piet Souris

Very basic Ant stuff <exec>

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I am trying some elementary stuff here and still I can't figure out how to do anything but move files and dirs around in this build tool.
I want to kick off a python script using ant:

<exec dir="C:\Python25" executable="python.exe">
<arg line="worldwind_to_jogl2" />

I get the:
Cannot run program "python.exe" (in directory "C:\Python25"): CreateProcess error=2, The system cannot find the file specified
Obviously that file is most defenitely there.

What am I doing wrong here?

This actually echos some DOS header stuff:
<exec dir="C:\Windows\System32" executable="cmd.exe">
so I doubt my settings are off.

I suppose I could run python by making ant open a cmd.exe and cd my way into Python25 and then issue a command python -filename.py
But so far any attempts to pass commands to cmd.exe failed. Is this tool even meant to do any of this?

Saloon Keeper
Posts: 22989
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Vit!

When executing applications in Ant scripts - and from Java programs in general, it doesn't pay to assume that the PATH is what you think it is. It is always good practice to explicitly specify exactly which copy of a program is to be run and from where. So instead of executable="python.exe", a better approach would be executable="C:/python2.5/python.exe".

Note that I used the forward-slash filename syntax. As a general rule, I recommend this form when working with Java. First, because it makes it possible to make scripts and code more portable. Secondly - and more importantly - the backslash character has another usage in Java and unless you're very careful it can bite you.
Posts: 5856
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the docs for the exec task, you will see this description for the "dir" attribute:

the directory in which the command should be executed.

I take this to mean the "current working directory" and not the directory that contains the executable.

There are two possible solutions - Tim mentioned one, the other is to add "c:\pyhton2.5" to the PATH.

I promise I will be the best, most loyal friend ever! All for this tiny ad:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic