kbforme has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am using Expect module of perl on UNIX. When I run the script, all the details are displayed on the console. Instead, I would like to have all the details displayed on the console to be logged into a log file.

I tried using

$exp->debug(1); $exp->log_file("server_install_log.txt", "w");

but, still the details are displayed on the console. The log file contains what was returned from previous send and what text was sent.

Could anyone please let me know how to acheive this? I just would like to have a clean console [or minimum details on console] and any other detail to be logged in a log file.

Any help is much appreciated.

Thanks

Edited by planetscape - added code tags and rudimentary formatting

( keep:0 edit:23 reap:0 )

Replies are listed 'Best First'.
Re: Logging details to log file
by perl_lover (Chaplain) on Sep 01, 2006 at 07:43 UTC
    If you are using send method to send strings then those strings will be echoed to the STDOUT unless you change the pty to raw mode.

    --- From the Expect POD ---
    $object->send(@strings)

    Sends the given strings to the spawned command. Note that the strings are not logged in the logfile (see print_log_file) but will probably be echoed back by the pty, depending on pty settings (default is echo) and thus end up there anyway. This must also be taken into account when expect()ing for an answer: the next string will be the command just sent. I suggest setting the pty to raw, which disables echo and makes the pty transparently act like a bidirectional pipe.