[TriLUG] Perl. Help. Needed.

Greg Brown gwbrown1 at gmail.com
Wed Mar 11 15:20:20 EDT 2009


I'm throwing my hands up in disgust.

My Perl/Expect.pm script prints to STDOUT just like it should.

I would like to redirect ONE PART OF THIS SCRIPT to a file from STDOUT

Code snippet:

        $ssh->expect(30,'(tcl)') || die "Never got the tcl prompt: $!\n";

        open(STDOUT, ">./configs/$fileName") || die "can't write to
./configs/$fileName: $!\n";

        print STDOUT "screw this script!!!!!  I"M SICK OF IT!\n";

        # now send the 'show run' comamnd
        print $ssh "exec \"show run\"\r";

        print STDOUT "AGAIN!  screw this script!!!!!  I"M SICK OF IT!\n";

        close (STDOUT);

Now when I run the script my outfile file contains "screw this script!!!!!
I"M SICK OF IT!"  and the "AGAIN" line - and ONLY those lines.. not the
result of the command run by the expect module.  To make matters more screwy
the results of 'show run' don't appear on the screen, i.e. they aren't going
to STDOUT.  But they aren't going to the redirected file either.

Why?

I don't want to log the output of the entire script, just this one command.
This should work.  If the results of my 'show run' aren't there when I
redirect STDOUT to a file and they are there when I don't where the hell
does it GO?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?

Beer please.



More information about the TriLUG mailing list