| |||||||||||
use return value of a script in the expect script Posted by pranav_nitt (pranav_nitt), 12 April 2004 Hello all,I am a beginner for the expect script. The problem i've encountered is as follows.. I have a expect script which telnets to a remote machine. subsequently i run a perl script from the expect script on that machine.. one of the subroutines in the perl script retunns a value , depending on which i have to proceed with the expect script... How do i access that return value in the expect script i will provide a outline of the things.. if return value of sub in perl is 1 no need to proceed further with expect script, i.e close the connection... else proceed with the expect script.... I will appreciate your help, Thanks , Pranav. Posted by admin (Graham Ellis), 12 April 2004 Have the Perl script print out the value that it returns rather that having it set a status code (I assume that's what you mean it does). You can then use the expect command to look for a string that matches each of the possibilities and brances depending on which it receives.Posted by pranav_nitt (pranav_nitt), 13 April 2004 thanks for the suggestion Graham.. but the problem that arises now is that how do i check for the output of the perl script , i mean is it possible to access that in my expect script will it be stored in some variable ( say something of type expect_out...) . Do let me know, Thanks, Pranav Posted by admin (Graham Ellis), 13 April 2004 Yes, but you need to have the Perl script print out the value that the subroutine returns. That value will then appear as part of your expect_out(buffer). It might be that you don't want (or can't) modify the output of the Perl program. If that's the case, then you can have your scripted telnet session run another command once the Perl program has completed to dump out the output file (or do whatever's necessary to get that vital subroutine return values onto the output stream). The connection between the two systems is purely the telnet session, so all values you want back in your expect program have to be part of that stream Posted by pranav_nitt (pranav_nitt), 13 April 2004 Hello Graham,the expect_out(buffer) would store the output until the correct match occurs, rite?? so in this case on encountring the prompt i immediately run the perl script on the remote machine.. so the output of that is not stored in the variable.. how do i get that output in the variable Please do let me know at the earliest, Thanks, Pranav Posted by admin (Graham Ellis), 13 April 2004 You print it out in your remote Perl program, use the expect command within your extended Tcl to match something that's towards the end of that printing, and then examine expect_out(string).Please note that this board is not intended as an emergency support facility - have a look at http://www.wellho.net/cgi-bin/opentalk/YaBB.pl?board=Assist;action=display;num=1081843563;start=0 where I've written a note about response times. This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |