perl: capturing STDOUT- logfile ends up binary
I wrote a script that feeds data into an exe program called ctffind. The exe program outputs a bunch of data to the screen which I'm trying to capture in a logfile.
Here's what I'm using right now
my $logout = logfile open STDOUT, '>>', "$logout"; open my $PIPE1, '|-', '/opt/ctf/ctffind3_mp.exe' or die $!;
It works outputting everything that appeared on the screen into logfile.
If I more $logfile the file displays as expected it's about 5000 lines long and has about 50 lines that contain the string "final values". In my next step I do grep "final values" logfile it thinks logfile is a binary file and doesn't work instead it returns:
Binary file logfile matches
How do set it so that logfile is properly encoded? ctffind.exe is also generating binary files while it runs, is this part of the problem?
I have found two different ways to resolve the problem, thanks to commenters' suggestions:
One can change the grep logfile to grep -a logfile.
One can use strings logfile logfile2 to make a usable version of the logfile.