One way is to redirect the output from your shell commands to files:
cd 2>/tmp/cd_err
This would execute the cd shell command and redirect the error result to the
file /tmp/cd_err. Be careful with this and make sure you check the file for
contents. The redirect will create the file even if there are no errors. It may
be easiest to create a shell script to do the work and have it do the error
result checking. Ant is not really a scripting language. It provides basically
rule based processing and does not have the primitives that are in shells like
bash, csh etc.
The cd should move you the the login default directory. The ssh should probably
put you in the same place. I suspect you are trying to cd to a different
location.
For processing what you are trying to do the following is an approach you may
want to consider:
cd 2>/tmp/cd_err
if [ -s /tmp/cd_err ]
then
echo "Error during cd command" > /tmp/error
exit 1
fi
This would execute the cd command and capture the error output. The if
statement tests that the file exists and is non 0 in size. If the file exists
and is non 0, the file /tmp/error is created and the script exits. If you want
to ftp the /tmp/error file back to the system you are calling from it would
occur before the exit. You can then test for the existence of the error file
where it would be returned and fail the build if it exists.
jpyork <[EMAIL PROTECTED]> wrote:
I am reading my Ant book and can't seem to get my scrip to write the overall
success/fail to a file. How would I do that because I have the script
failing on the first task and I can't seem to get it to spitout a file
because nothing runs after it fails.
Chuck Holzwarth wrote:
>
> One issue is that you are running the second ant build on a different
> system, potentially, via ssh. The error may be transmitted to the shell
> that is running, but not transmitted back to the parent script. On the
> local system you may see the result of being able to issue the ssh command
> but not result of running the ant script. The docs are not clear on that.
> There is a difference in having the ability to run an ssh and the error
> results produced on the remote system during the ssh. From the target, you
> are issuing multiple commands on the remote system and not trapping the
> errors from any of them. Remember that the "cd" command can fail and you
> are not where you expect to be but the sshexec probably will not fail.
>
> It may be easier to have your ant script on the remote machine write the
> success to a file and ftp it back to check the error status. Using a file
> based semaphore is often the best way to get status results since it is
> generally portable among operating systems. This can give you more
> granular information than just that an error has occurred.
>
> Thank you,
> Chuck Holzwarth
> (804) 403-3478 (home)
> (540) 335-3171 (cell)
>
> ----- Original Message ----
> From: jpyork
> To: [email protected]
> Sent: Monday, January 21, 2008 1:30:44 PM
> Subject: RE: Halt Ant script question
>
>
>
> This is the start of the target I use:
>
>
>
>
> file="../../../../../Builds/test/abc-${buildVersion}.war"
> todir="${scp.url}" trust="true"/>
>
>
>
> username="${host.autodeploy.username}"
> password="${host.autodeploy.pw}"
> output="deploy.log"
> append="true"
> command="cd;
>
> echo 'Starting Deployment';
>
>
>
> cd '/test/home/asadmin';
>
>
>
> echo 'Triggering Deployment script on Server';
> /opt/SUNWappserver/bin/asant
> -DbuildVersion=${buildVersion} -buildfile
> deploy_build.xml;
>
>
>
>
>
>
>
>
> Toomey, Kevin H (ATS, IT) wrote:
>>
>> Can you give an example of how the first script is calling the
> second? Are
>> you using , or , or , or something else?
>>
>> -----Original Message-----
>> From: jpyork [mailto:[EMAIL PROTECTED]
>> Sent: Monday, January 21, 2008 11:58 AM
>> To: [email protected]
>> Subject: Halt Ant script question
>>
>>
>>
>> I am running 2 scripts and my problem is when the first script runs
> and
>> the
>> calls the 2nd one, sometimes the 2nd one will fail and that does not
> cause
>> my 1st one to fail.
>>
>> I am looking for a way to have my main script halt/fail if the 2nd
> script
>> does not work. What is the task to do this?
>> --
>> View this message in context:
>>
> http://www.nabble.com/Halt-Ant-script-question-tp15001659p15001659.html
>> Sent from the Ant - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>
> *************************************************************************
>> This communication, including attachments, is
>> for the exclusive use of addressee and may contain proprietary,
>> confidential and/or privileged information. If you are not the
> intended
>> recipient, any use, copying, disclosure, dissemination or
> distribution is
>> strictly prohibited. If you are not the intended recipient, please
> notify
>> the sender immediately by return e-mail, delete this communication
> and
>> destroy all copies.
>>
> *************************************************************************
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Halt-Ant-script-question-tp15001659p15003355.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>
>
>
>
> ____________________________________________________________________________________
> Never miss a thing. Make Yahoo your home page.
> http://www.yahoo.com/r/hs
>
--
View this message in context:
http://www.nabble.com/Halt-Ant-script-question-tp15001659p15027602.html
Sent from the Ant - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Thank you,
Chuck Holzwarth
(804) 403-3478 (home)
(540) 335-3171 (cell)
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.