i am using net:telnet module to login to the remote machine and execute some commands and to collect some logs corresponding to the command given.
After loging into the machine I do patternmatch for a string and collect the logs and store it in a file.
The code for the same is given below.
Expand|Select|Wrap|Line Numbers
- $telnet->print('cmd1');#command to be executed
- sleep(5);
- ($prematch,$match) = $telnet->waitfor(
- String => "2>",
- Timeout => 10 ,
- Errmode => 'return',
- );
- open(OUTFILE1,">x");
- print OUTFILE1 ($prematch);#copying the logs of cmd into a file.
- close(OUTFILE1);
I need to modify the code in such a way that all the logs must be stored in the file even if I cont match any pattern(bcoz logs will be varying
I will not be able match any pattern)I just tried giving String => "" but it doesnot work and the content of the file "x"is zero.
I did some search in google and the info i got is
The waitfor() method is the workhorse of Net::Telnet. It waits up to Timeout seconds for the specified string or pattern to appear on the data stream coming from the remote host. In a scalar context, waitfor() returns a true value if the desired pattern was seen.
The issue here is I cont match any pattern in that case how can I get the logs from remote host.
Any pointers in solving it will be helpful.