ant change directory command

P

pankajgautam

I'm trying to use cd command in ant

here is the syntax
<exec executable="cd checkouts/${TODAY_UK}">

the error I'm getting is

BUILD FAILED
/builds/cruise/build.xml:33: Execute failed: java.io.IOException:
java.io.IOException: cd checkouts/10-August-2005-111916: not found

I'm not sure what is wrong here, any help is appreciated
thanks,
-pankaj
 
G

Gordon Beaton

I'm trying to use cd command in ant

here is the syntax
<exec executable="cd checkouts/${TODAY_UK}">

the error I'm getting is

BUILD FAILED
/builds/cruise/build.xml:33: Execute failed: java.io.IOException:
java.io.IOException: cd checkouts/10-August-2005-111916: not found

There is no executable named cd!

And for good reason too, because the *only* way for a process to
change its working directory is to do it itself with a system call,
something no external utility can do on its behalf. (The cd you
normally use from your command shell is a built in mechanism).

/gordon
 
P

pankajgautam

alright

syntax:
<exec executable="bash">
<arg value="cd checkouts/${TODAY_UK}"/>

error:
[exec] cd checkouts/10-August-2005-115831: cd
checkouts/10-August-2005-115831: No such file or directory

this works but for some reason, it put a extra : after the directory
which generates the above error

any clue ?
-pankaj
 
G

Gordon Beaton

syntax:
<exec executable="bash">
<arg value="cd checkouts/${TODAY_UK}"/>

error:
[exec] cd checkouts/10-August-2005-115831: cd
n> checkouts/10-August-2005-115831: No such file or directory
this works but for some reason, it put a extra : after the directory
which generates the above error

The colon is not the problem, it's part of the error message. I
believe that bash is telling you it couldn't find a file called
"cd checkouts/10-August-2005-115831".

I don't know Ant or how it passes arguments to subprocesses, but there
are two things that need to be considered here:

1. when you pass a command line to bash, you need to specify -c and
group the arguments like this:

argv[0]: bash
argv[1]: -c
argv[2]: the complete command line you want to execute

2. you *still* can't change your working directory like that. Yes, you
will cause the executed bash to change its *own* working directory,
but it immediately exits and your calling process is left where it
started.

Here's an example:

[foo]$ pwd
~gordon

[foo]$ bash -c "cd slask"
[foo]$ pwd
~gordon

[foo]$ cd slask
[foo]$ pwd
~gordon/slask

In order for it to be possible to change directories in your Ant
script, Ant itself must provide a built in mechanism to do so.

/gordon
 
R

Roedy Green

I'm trying to use cd command in ant

here is the syntax
<exec executable="cd checkouts/${TODAY_UK}">

the error I'm getting is

BUILD FAILED
/builds/cruise/build.xml:33: Execute failed: java.io.IOException:
java.io.IOException: cd checkouts/10-August-2005-111916: not found

First of all, ant has base.dir instead of cd which is what you really
want to change.

Next exec only handles real exes. There is no cd.exe or cd.com. It is
just a command passed to a command interpreter such as 4NT.exe or
cmd.exe. You must exec cmd.exe and pass that your CD command.
However, that would not do you any good since cd only has meaning
within an incarnation of a command interpreter. As soon as cmd.exe
returned the effect would disappear.

Best to resign yourself to the idea you should not attempt to change
the cwd in Java or Ant.
 
P

pankajgautam

alright -
understood. if I have resign the idea of cd, can I use link command in
ant

<exec executable="bash">
<arg value="ln -s checkouts/${TODAY_UK}/project1 project1">

is this posible??
 
R

Raymond DeCampo

pankajgautam said:
alright -
understood. if I have resign the idea of cd, can I use link command in
ant

<exec executable="bash">
<arg value="ln -s checkouts/${TODAY_UK}/project1 project1">

is this posible??

It's possible, but not the way you have written it.

Perhaps it would be more helpful to explain what you are really trying
to do, instead of explaining your solutions and trying to get them to
work. Likely somebody here will have a nice solution to your problem.

HTH,
Ray
 
P

pankajgautam

well, this is my first experience with ANT
and trying to automate our build process, but thanks again all of you
for your response.
currently everything looks good, now I'm trying to find ways how to
deploy these builds on windows server.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top