Nov 3, 2010 12:06 am
Bryan R HarrisI have these lines in my script:
**************************************
for my $handle (*STDIN, *STDERR) {
open($handle, "+</dev/null") or die "$me: Can't reopen $handle to
/dev/null: $!. Exiting.\n";
}
# open outfile for further recording
open(STDOUT,">$outfile") or die "$me: Couldn't open $outfile: $!\n";
$| = 1; # and don't buffer it
**************************************
I decided I want STDERR to also be redirected to the same outfile as STDOUT
instead of sending it to /dev/null. Is that possible?
TIA.
- Bryan
Nov 3, 2010 4:16 am
C.DeRykusOn Nov 2, 5:06?pm, Bryan_R_Har...@raytheon.com (Bryan R Harris) wrote:
> I have these lines in my script:
>
> **************************************
> for my $handle (*STDIN, *STDERR) {
> ? ? open($handle, "+</dev/null") or die "$me: ?Can't reopen $handle to
> /dev/null: $!. ?Exiting.\n";
>
> }
>
> # open outfile for further recording
> open(STDOUT,">$outfile") or die "$me: ?Couldn't open $outfile: ?$!\n";
> $| = 1; ? ? ? ? # and don't buffer it
> **************************************
>
> I decided I want STDERR to also be redirected to the same outfile as STDOUT
> instead of sending it to /dev/null. ?Is that possible?
>
>
> **************************************
> for my $handle (*STDIN, *STDERR) {
> ? ? open($handle, "+</dev/null") or die "$me: ?Can't reopen $handle to
> /dev/null: $!. ?Exiting.\n";
>
> }
>
> # open outfile for further recording
> open(STDOUT,">$outfile") or die "$me: ?Couldn't open $outfile: ?$!\n";
> $| = 1; ? ? ? ? # and don't buffer it
> **************************************
>
> I decided I want STDERR to also be redirected to the same outfile as STDOUT
> instead of sending it to /dev/null. ?Is that possible?
>
perldoc perlopentut and look for: Re-Opening Files (dups)
--
Charles DeRykus
Nov 4, 2010 12:43 pm
Bryan HarrisThank you!
> On Nov 2, 5:06=A0pm, Bryan_R_Har...@raytheon.com (Bryan R Harris) wrote:
OUT>> I have these lines in my script:
>>=20
>> **************************************
>> for my $handle (*STDIN, *STDERR) {
>> =A0 =A0 open($handle, "+</dev/null") or die "$me: =A0Can't reopen $handle to
>> /dev/null: $!. =A0Exiting.\n";
>>=20
>> }
>>=20
>> # open outfile for further recording
>> open(STDOUT,">$outfile") or die "$me: =A0Couldn't open $outfile: =A0$!\n";
>> $| =3D 1; =A0 =A0 =A0 =A0 # and don't buffer it
>> **************************************
>>=20
>> I decided I want STDERR to also be redirected to the same outfile as STD=
>>=20
>> **************************************
>> for my $handle (*STDIN, *STDERR) {
>> =A0 =A0 open($handle, "+</dev/null") or die "$me: =A0Can't reopen $handle to
>> /dev/null: $!. =A0Exiting.\n";
>>=20
>> }
>>=20
>> # open outfile for further recording
>> open(STDOUT,">$outfile") or die "$me: =A0Couldn't open $outfile: =A0$!\n";
>> $| =3D 1; =A0 =A0 =A0 =A0 # and don't buffer it
>> **************************************
>>=20
>> I decided I want STDERR to also be redirected to the same outfile as STD=
>> instead of sending it to /dev/null. =A0Is that possible?
>>=20
>=20>>=20
> perldoc perlopentut and look for: Re-Opening Files (dups)
>=20
> --
> Charles DeRykus
>=20
>=20
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>=20
>=20
Previous Thread: Re: Subroutine question: Placement of subroutine definitions matter?
Next Thread: How to compare 2 elements in an array
Related Forum Topics
- Redirecting STDERR with IO::Tee
- Can not mix output of STDERR and STDOUT
- How to print errors to both STDERR & a file?
- Redirecting STDOUT and STDERR for system()
- How to catch error message instead of printing to stderr for rmtree
- Mechanize Redirect
- Redirect option
- How to do absolute redirect in perl
- Redirect Find::File to /dev/null
- How to redirect in system command two devices at once