You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by ritchie <ga...@baml.com> on 2011/02/04 16:08:50 UTC

To check server is down

Is there a ant task to check whether the server hosting the source control is
down?
-- 
View this message in context: http://ant.1045680.n5.nabble.com/To-check-server-is-down-tp3371133p3371133.html
Sent from the Ant - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


sshexec behaviour

Posted by Maureen Troendle <tr...@ca.ibm.com>.
I'm using Ant version 1.7.0 on AIX 5.3 servers and I'm seeing some odd 
behavior, just wondering if anyone else has encountered this.  I'm copying 
some zip files over to another server, unzipping them, ssh'ing and doing a 
chmod u+x, then trying to execute one of the scripts.
It seems everytime I add an sshexec to execute a script, I lose my chmod 
permission changes.  I can do an ls -al before and after the chmod in the 
same sshexec line and see the permissions change.   I can also run a 2nd 
sshexec with ls -al and see the permissions are still correct.  When I add 
the additional sshexec to try and execute one of the scripts, I get errors 
and I see that the permissions change on the remote server is not there.

So either I'm getting false reporting on which line is failing and the 
chmod is inconsistently failing or somehow the sshexec to run the script 
is somehow affecting the previous ssh command.  If the first sshexec for 
the chmod failed due to server timeout or something similar, I would 
expect an error like "Remote command failed with exit status -1" not the 
errors I am seeing flagging the script executing sshexec line.

It seems as though I need to remove the script executing sshexec line to 
get the chmod to work again. (ie. multiple reruns of script doesn't help). 
 I can see in the output of the execution that it is getting changed, yet 
when I look on the remote server the perms are not changed?

I've tried to test out a few theories like:
1. does a regular cmd rather than sshexec succeed after the chmod sshexec 
and are perms still correct - yes (echo)
2. is it being caused by the user being in the folders that are being 
removed/recreated on remote server while that activity is running - no
3. can I run a different sshexec cmd and have it succeed - yes, sshexec 
with ls -al succeeds

If anyone has any ideas or suggestions, I'd appreciated them.

Here's a sample of the code:
    <echo message="== make scripts executable at 
${target.fldr.path}/Workbooks/s
cripts/DeploymentScripts ==" />
    <sshexec host="${target.server}" username="${target.user}" 
password="${targe
t.password}" failonerror="true" trust="true" output="${target.log}" 
append="true
" command="cd ${target.fldr.path}/Workbooks/scripts/DeploymentScripts; ls 
-al; c
hmod u+x ${target.fldr.path}/Workbooks/scripts/DeploymentScripts/*.ksh; ls 
-al"
/>
    <echo message="== did config stick after adding a next cmd ==" />
    <echo message="== see if problem is user in folder when executing 
chmod =="
/>
    <echo message="== remove ^Ms from 
${target.fldr.path}/Workbooks/scripts/Depl
oymentScripts ==" />               <- misnomer here, running sshexec with 
ls -al
    <sshexec host="${target.server}" username="${target.user}" 
password="${targe
t.password}" failonerror="true" trust="true" output="${target.log}" 
append="true
" command="cd ${target.fldr.path}/Workbooks/scripts/DeploymentScripts; ls 
-al"/>

    <echo message="== remove ^Ms from 
${target.fldr.path}/Workbooks/scripts/Depl
oymentScripts ==" />
    <sshexec host="${target.server}" username="${target.user}" 
password="${targe
t.password}" failonerror="true" trust="true" output="${target.log}" 
append="true
" 
command="${target.fldr.path}/Workbooks/scripts/DeploymentScripts/remove_contro
lM.ksh ksh" />

And a sample of the output:
     [echo] == make scripts executable at 
/tmp/bcydeploy/D2/01_Config/Workbooks/scripts/DeploymentScripts ==
  [sshexec] Connecting to servername:22
  [sshexec] total 24                                        <- ls before 
chmod
  [sshexec] drwxr-xr-x    2 user group           256 Jan 07 09:57 .
  [sshexec] drwxr-xr-x    3 user group           256 Jan 07 09:57 ..
  [sshexec] -rw-r--r--    1 user group          1657 Feb 08 17:48 
Iterm_Config_Workbook_loading.csv
  [sshexec] -rw-r--r--    1 user group          3788 Oct 07 09:17 
bcyConfigureITERM.ksh
  [sshexec] -rw-r--r--    1 user group          531 Mar 16 2010 
remove_controlM.ksh
  [sshexec] total 24                                          <- ls after 
chmod
  [sshexec] drwxr-xr-x    2 user group           256 Jan 07 09:57 .
  [sshexec] drwxr-xr-x    3 user group           256 Jan 07 09:57 ..
  [sshexec] -rw-r--r--    1 user group          1657 Feb 08 17:48 
Iterm_Config_Workbook_loading.csv
  [sshexec] -rwxr--r--    1 user group          3788 Oct 07 09:17 
bcyConfigureITERM.ksh
  [sshexec] -rwxr--r--    1 user group           531 Mar 16 2010 
remove_controlM.ksh
     [echo] == did config stick after adding a next cmd ==
     [echo] == see if problem is user in folder when executing chmod ==
     [echo] == remove ^Ms from 
/tmp/bcydeploy/D2/01_Config/Workbooks/scripts/DeploymentScripts ==
  [sshexec] Connecting to servername:22
  [sshexec] total 24                                     <- ls in separate 
sshexec
  [sshexec] drwxr-xr-x    2 user group           256 Jan 07 09:57 .
  [sshexec] drwxr-xr-x    3 user group           256 Jan 07 09:57 ..
  [sshexec] -rw-r--r--    1 user group          1657 Feb 08 17:48 
Iterm_Config_Workbook_loading.csv
  [sshexec] -rwxr--r--    1 user group          3788 Oct 07 09:17 
bcyConfigureITERM.ksh
  [sshexec] -rwxr--r--    1 user group           531 Mar 16 2010 
remove_controlM.ksh
     [echo] == remove ^Ms from 
/tmp/bcydeploy/D2/01_Config/Workbooks/scripts/DeploymentScripts ==
  [sshexec] Connecting to servername:22         <- with only 1 run of cmd, 
looks like succeeds but doesn't execute properly on files, if repeat 
command with other options/methods, get failures

BUILD SUCCESSFUL
Total time: 39 seconds

2nd sample of output showing failures
  [sshexec] Connecting to servername:22
     [echo] == make scripts executable at 
/tmp/bcydeploy/D2/01_Config/Workbooks/scripts/DeploymentScripts ==
  [sshexec] Connecting to servername:22            <-extra ls's around 
chmod were removed
     [echo] == did config stick after adding a next cmd ==
     [echo] == see if problem is user in folder when executing chmod ==
     [echo] == remove ^Ms from 
/tmp/bcydeploy/D2/01_Config/Workbooks/scripts/DeploymentScripts ==
  [sshexec] Connecting to servername:22            <-separate ls in own 
sshexec
  [sshexec] total 24
  [sshexec] drwxr-xr-x    2 user group           256 Jan 07 09:57 .
  [sshexec] drwxr-xr-x    3 user group           256 Jan 07 09:57 ..
  [sshexec] -rw-r--r--    1 user group          1657 Feb 08 17:48 
Iterm_Config_Workbook_loading.csv
  [sshexec] -rwxr--r--    1 user group         3788 Oct 07 09:17 
bcyConfigureITERM.ksh
  [sshexec] -rwxr--r--    1 user group           531 Mar 16 2010 
remove_controlM.ksh
     [echo] == remove ^Ms from 
/tmp/bcydeploy/D2/01_Config/Workbooks/scripts/DeploymentScripts ==
  [sshexec] Connecting to servername:22
  [sshexec] ksh: 
/tmp/bcydeploy/D2/01_Config/Workbooks/scripts/DeploymentScripts/remove_controlM.ksh: 
cannot execute

BUILD FAILED
/path/bcydeploy.xml:191: Remote command failed with exit status 126

Code generating 2nd sample
    <echo message="== make scripts executable at 
${target.fldr.path}/Workbooks/s
cripts/DeploymentScripts ==" />
    <sshexec host="${target.server}" username="${target.user}" 
password="${targe
t.password}" failonerror="true" trust="true" output="${target.log}" 
append="true
" command="chmod u+x 
${target.fldr.path}/Workbooks/scripts/DeploymentScripts/*.k
sh" />
    <echo message="== did config stick after adding a next cmd ==" />
    <echo message="== see if problem is user in folder when executing 
chmod =="
/>
    <echo message="== remove ^Ms from 
${target.fldr.path}/Workbooks/scripts/Depl
oymentScripts ==" />
    <sshexec host="${target.server}" username="${target.user}" 
password="${targe
t.password}" failonerror="true" trust="true" output="${target.log}" 
append="true
" command="cd ${target.fldr.path}/Workbooks/scripts/DeploymentScripts; ls 
-al"/>

    <echo message="== remove ^Ms from 
${target.fldr.path}/Workbooks/scripts/Depl
oymentScripts ==" />
    <sshexec host="${target.server}" username="${target.user}" 
password="${targe
t.password}" failonerror="true" trust="true" output="${target.log}" 
append="true
" command="cd ${target.fldr.path}/Workbooks/scripts/DeploymentScripts; 
${target.
fldr.path}/Workbooks/scripts/DeploymentScripts/remove_controlM.ksh ksh; 
${target
.fldr.path}/Workbooks/scripts/DeploymentScripts/remove_controlM.ksh csv" 
/>


Regards,
Maureen



Re: To check server is down

Posted by Steve Loughran <st...@apache.org>.
On 04/02/11 15:34, Martin Gainty wrote:
>
> svn:// URLs are on port 3960
> discover-target would need to test netstat output e.g.
> netstat -a | grep 3960>output.file
> a fail message would be no output
> a found message would be the IP:3960 of the server
>
> OR in the case of ssh+svn
> netstat -a | grep 22>output.file
> a fail message would be no output
>
> a found message would be the IP:3960 of the server

There's a risk there that if /etc/services is up to date, the netstat 
won't show 22, it will show svn.

I'd use the <socket>

<fail>
   <condition>
   <not><socket port="3960" server="127.0.0.1" /></not>
  </condition>
  No SVN server
</fail>

I use this kind of check in <waitfor>, blocking for something to go live 
before running the unit tests against it

-steve

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: To check server is down

Posted by Martin Gainty <mg...@hotmail.com>.
svn:// URLs are on port 3960
discover-target would need to test netstat output e.g.
netstat -a | grep 3960 >output.file
a fail message would be no output
a found message would be the IP:3960 of the server

OR in the case of ssh+svn
netstat -a | grep 22 >output.file
a fail message would be no output

a found message would be the IP:3960 of the server


build.xml chronology of execution would be:
delete output.file
task the first discover-target (which will be the 1st target) to execute netstat and create an output.file
task the second target to have a dependency on the first discover-target and then wait for 5 seconds
test for the existence of the output.file from the 1st discover-target.. if output-file is there you're good to go

hth,
Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Fri, 4 Feb 2011 07:08:50 -0800
> From: ganesh.devarajulu@baml.com
> To: user@ant.apache.org
> Subject: To check server is down
> 
> 
> Is there a ant task to check whether the server hosting the source control is
> down?
> -- 
> View this message in context: http://ant.1045680.n5.nabble.com/To-check-server-is-down-tp3371133p3371133.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>