LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   CGI script problem: Send/Expect command echo on webpage (https://www.linuxquestions.org/questions/programming-9/cgi-script-problem-send-expect-command-echo-on-webpage-203799/)

rajatgarg 07-11-2004 03:34 PM

CGI script problem: Send/Expect command echo on webpage
 
Hi,

I am writing a CGI script which calls a perl script to remotely login to a machine using send/expect commands. Problem is that all those messages get
printed on webpage. How to tackle these ?
Kindly let me know.....

Regards,
Rajat Garg
Student
Stanford University

born4linux 07-11-2004 04:15 PM

assuming that you are using Apache, look for "Apache CGI howto" via google.com/linux.

jovo 07-11-2004 04:38 PM

Everything printed to stdout inside a CGI-script is sent to the browser. The browser tries to make something from it. I think you must do something like

my $reply=`MyExpectScript`;

Note: use backticks!!!!!

Now everything your script prints is put as a string in $reply.

So the next code will be

# do something with the data in $reply
....
....
print "..... the results you want to see....."

for instance if you just want to show all the lines on your screen

for my $line (split(/\n/,$reply)) {
print "$line<BR>\n";
}


All times are GMT -5. The time now is 06:18 AM.