Y
yaru22
Hi,
I noticed that whenever I log in to another machine through sshexec
and execute some commands,
it leaves the process there even when the commands are finished.
I created run-ssh macro as following:
<macrodef name="run-ssh">
<attribute name="rmt.host"/>
<attribute name="failonerror" default="true"/>
<!-- Since ANT doesn't read .profile when ssh,
we have to make it read .profile -->
<attribute name="default.cmd" default=". ~/.profile"/>
<attribute name="out.file"/>
<attribute name="run.cmd"/>
<attribute name="userID" default="${testerID}"/>
<attribute name="userPWD" default="${testerPWD}"/>
<attribute name="timeout" default="0"/>
<sequential>
<sshexec host="@{rmt.host}"
trust="yes"
username="@{userID}"
password="@{userPWD}"
output="@{out.file}"
command="@{default.cmd}; @{run.cmd}"
failonerror="@{failonerror}"
timeout="@{timeout}"
keyfile="${env.USERPROFILE}/.ssh/id_dsa"/>
</sequential>
</macrodef>
And I use this macro as follows somewhere in the script:
<run-ssh rmt.host="@{host.name}" failonerror="false"
out.file="kill_procs_@{host.name}.log"
run.cmd="${pretest_home}/stubbornProcs.sh; exit"/
The reason I have 'exit' at the end there is that I thought it would
help terminate the process but it doesn't.
After the ANT script runs, I manually connected to the machine and
checked the processes
ps -fu <userID>
Then it showed:
UID PID PPID C STIME TTY TIME CMD
<userID> 4849 4847 0 Feb26 ? 00:00:00 sshd:
<userID>@notty
I had so many of "sshd: <userID>@notty" on the list.
Does anyone know how to terminate the process cleanly on ANT script so
that I don't have to manually kill those processes?
Thank you.
I noticed that whenever I log in to another machine through sshexec
and execute some commands,
it leaves the process there even when the commands are finished.
I created run-ssh macro as following:
<macrodef name="run-ssh">
<attribute name="rmt.host"/>
<attribute name="failonerror" default="true"/>
<!-- Since ANT doesn't read .profile when ssh,
we have to make it read .profile -->
<attribute name="default.cmd" default=". ~/.profile"/>
<attribute name="out.file"/>
<attribute name="run.cmd"/>
<attribute name="userID" default="${testerID}"/>
<attribute name="userPWD" default="${testerPWD}"/>
<attribute name="timeout" default="0"/>
<sequential>
<sshexec host="@{rmt.host}"
trust="yes"
username="@{userID}"
password="@{userPWD}"
output="@{out.file}"
command="@{default.cmd}; @{run.cmd}"
failonerror="@{failonerror}"
timeout="@{timeout}"
keyfile="${env.USERPROFILE}/.ssh/id_dsa"/>
</sequential>
</macrodef>
And I use this macro as follows somewhere in the script:
<run-ssh rmt.host="@{host.name}" failonerror="false"
out.file="kill_procs_@{host.name}.log"
run.cmd="${pretest_home}/stubbornProcs.sh; exit"/
The reason I have 'exit' at the end there is that I thought it would
help terminate the process but it doesn't.
After the ANT script runs, I manually connected to the machine and
checked the processes
ps -fu <userID>
Then it showed:
UID PID PPID C STIME TTY TIME CMD
<userID> 4849 4847 0 Feb26 ? 00:00:00 sshd:
<userID>@notty
I had so many of "sshd: <userID>@notty" on the list.
Does anyone know how to terminate the process cleanly on ANT script so
that I don't have to manually kill those processes?
Thank you.