tags:

views:

129

answers:

1

Hi I am using expect in perl. I want to redirect all the output that appears on the stdout console to a log file so that i can debug it in future. Currently i am using $exp->log_stdout(0); Instead of redirecting to this can i do it to a log file? if so how to do it?

A: 

if you see the documentation of Expect, you will find information about Log session to a file

$object->log_file("filename" | $filehandle | \&coderef | undef)

All characters send to or received from the spawned process are written to the file. Normally appends to the logfile, but you can pass an additional mode of "w" to truncate the file upon open():

$object->log_file("filename", "w");

That means use log_file method instead of log_stdout.

Your problem will be solved.

Nikhil Jain
Hi The solution is working. but is there any option to append the file. cos i am using this in function. and everytime the funciton is called it is overwriting the already existing file. thanks
shayam
@shayam: see the documentation of Expect, you will find each and every thing.
Nikhil Jain