Patrick & all
This is what I did to get this done:
1. Following Patrick's advice, I ran the commands manually and capture the output
2. Set several properties with the values expected
3. Update the target with:
<target name="callScript">
<telnet server="${target.server}">
<read timeout="10">ogin:</read> <!-- Notice there are no spaces
between the '>' and '<' characters-->
<write echo="true">${user.id}</write> <!-- Do not try to send
CR or LF chars here. It doesn't work-->
<read timeout="10">assword:</read> <!-- Notice there are no spaces
between the '>' and '<' characters-->
<write>${user.pwd}</write>
<read timeout="10">${prompt}</read>
<write echo="true">${script}</write>
<read timeout="10">${prompt}</read>
<write echo="true">exit</write>
</telnet>
</target>
The [timeout] attribute it is pretty usefull to know which element is falling (read / write)
Appreciate your advice & time.
Regards
Luis
-----Original Message-----
From: CONANT,PATRICK (HP-FtCollins,ex1) [mailto:patrick.conant@hp.com]
Sent: Thursday, January 29, 2004 6:13 PM
To: 'Ant Users List'
Subject: RE: Telnet Task Issue
Actually, no patch needed -- it looks like the additional logging is already
available in CVS.
--p.
-----Original Message-----
From: CONANT,PATRICK (HP-FtCollins,ex1)
Sent: Thursday, January 29, 2004 5:09 PM
To: 'Ant Users List'
Subject: RE: Telnet Task Issue
I'd recommend running the commands manually over a telnet session to the
server. Capture the response from the server, and use that in your <read>
elements. In addition, you can add a timeout attribute to the read element
to cause the build to fail if you don't get the output you expected. If you
still have trouble, post the updated telnet task and all the nested
read/write elements.
I've noted that when the telnet task does timeout, it does not log what it
has read so far. This makes debugging the telnet sessions difficult. I'll
submit a patch for this soon.
--p.
-----Original Message-----
From: Conelly, Luis (PS, GNF, Contractor) [mailto:Luis.Conelly@gnf.com]
Sent: Thursday, January 29, 2004 4:28 PM
To: Ant Users List
Subject: RE: Telnet Task Issue
Patrick & all,
Thanks for the quick prompt. I tried to do what you mentioned [this
is, change the <read/> element for "<read>blahblahblah</read>"]; however,
the task gets hang forever. I do not know if this is due to my OS or what...
I'll keep looking, but any help is greatly appreciated.
Regards
-Luis
-----Original Message-----
From: CONANT,PATRICK (HP-FtCollins,ex1) [mailto:patrick.conant@hp.com]
Sent: Thursday, January 29, 2004 5:18 PM
To: 'Ant Users List'
Subject: RE: Telnet Task Issue
You might try reading something back to prevent the telnet connection from
being closed before the commands are received by the remote system. Try
replacing your "<read/>" elements with "<read>blahblahblah</read>" where
"blahblahblah" is what you expect to be sent from the telnet server to the
client after each command is executed (e.g. a command prompt or the output
of the previous command).
--p.
-----Original Message-----
From: Conelly, Luis (PS, GNF, Contractor) [mailto:Luis.Conelly@gnf.com]
Sent: Thursday, January 29, 2004 3:56 PM
To: user@ant.apache.org
Subject: Telnet Task Issue
Hi all,
I am having an issue with <telnet> task. I am trying to execute a simple
script via ant to a *nix server [Red Hat Linux release 7.2 (Enigma)]
This is the snippet of the script:
<target name="callScript">
<telnet userid="${user.id}" password="${user.id}"
server="${target.server}">
<read/>
<write echo="true"> sh /scripts/k2kftp.sh </write>
<read/>
<write echo="true">exit</write>
</telnet>
</target>
And the output looks like:
Buildfile: telnet_tools.xml
callScript:
[telnet] Red Hat Linux release 7.2 (Enigma)
[telnet] Kernel 2.4.7-10 on an i686
[telnet] login:
[telnet] xxxxxx
[telnet] Password:
[telnet] sh /scripts/k2kftp.sh
[telnet] exit
BUILD SUCCESSFUL
Total time: 1 second
However, the script does not get executed. I have tried to execute
simpler [such as ls], but it doesn't get a thing. Does anybody has an idea
about why is this happening?
Regards
-Luis
Settings:
Workstation OS: Win2K Pro
Ant: 1.6beta2
JDK: 1.4.1_02
Server OS: Red Hat Linux release 7.2 (Enigma)
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org