redirection failure (may be newbie question,

This is a multipart message in MIME format.
--===============1364743079==
Content-Type: multipart/alternative;
boundary="=_alternative 005E17E886257273_="

This is a multipart message in MIME format.
--=_alternative 005E17E886257273_=
Content-Type: text/plain; charset="us-ascii"

Wizards,

....Or it may be just that it's something new for me...

I'm trying to redirect the output of a file copy away from stdout so a
scheduled script won't leave a big muddy "1 file(s) copied" mess on the
(non-visible) screen. I checked in the panther book and got the suggested
redirection command,

*STDOUT = *F;

but in my code, I'm still seeing the copied message on my screen. I tried
the classic "2>&1" redirect embedded in the system call that does the
actual copying, but that didn't help either. So I must be missing
something. Here's the relevant code:

# Redirect stdout so "file(s) copied" message goes to log file, not
screen.
*STDOUT = *LOG;

# create values for $edit_file and $save_file here, then...

system( "copy \"$edit_file\" \"$save_file\" /y" );

Is it the system call itself that's keeping me from getting the desired
results?

Thanks,

Deane Rothenmaier
Systems Architect
Walgreens Corp.
847-914-5150

"On two occasions I have been asked [by members of Parliament], 'Pray, Mr.
Babbage, if you put into the machine wrong figures, will the right answers
come out?' I am not able rightly to apprehend the kind of confusion of
ideas that could provoke such a question." -- Charles Babbage
--=_alternative 005E17E886257273_=
Content-Type: text/html; charset="us-ascii"


<br><font size=2 face="sans-serif">Wizards,</font>
<br>
<br><font size=2 face="sans-serif">...Or it may be just that it's something new for me...</font>
<br>
<br><font size=2 face="sans-serif">I'm trying to redirect the output of a file copy away from stdout so a scheduled script won't leave a big muddy "1 file(s) copied" mess on the (non-visible) screen. I checked in the panther book and got the suggested redirection command,</font>
<br>
<br><font size=2 face="sans-serif">  *STDOUT = *F;</font>
<br>
<br><font size=2 face="sans-serif">but in my code, I'm still seeing the copied message on my screen. I tried the classic "2>&1" redirect embedded in the system call that does the actual copying, but that didn't help either. So I must be missing something. Here's the relevant code:</font>
<br>
<br><font size=2 face="Courier New">   # Redirect stdout so "file(s) copied" message goes to log file, not screen.</font>
<br><font size=2 face="Courier New">   *STDOUT = *LOG;</font>
<br>
<br><font size=2 face="Courier New">   # create values for $edit_file and $save_file here, then...</font>
<br>
<br><font size=2 face="Courier New">   system( "copy \"$edit_file\" \"$save_file\" /y" );</font><font size=2 face="sans-serif"><br>
</font>
<br><font size=2 face="sans-serif"> Is it the system call itself that's keeping me from getting the desired results?</font>
<br>
<br><font size=2 face="sans-serif">Thanks,</font>
<br>
<br><font size=2 face="sans-serif">Deane Rothenmaier<br>
Systems Architect<br>
Walgreens Corp.<br>
847-914-5150<br>
<br>
"On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question." -- Charles Babbage</font>
--=_alternative 005E17E886257273_=--


--===============1364743079==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1364743079==--
Deane.Rothenmaier [ Di, 30 Januar 2007 18:07 ] [ ID #1613463 ]

Re: redirection failure (may be newbie question,

This is a multi-part message in MIME format.

--===============0232236703==
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_2517_01C7449E.A5B89F10"

This is a multi-part message in MIME format.

------=_NextPart_000_2517_01C7449E.A5B89F10
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Deane,

The construct '2>&1' won't help here - it redirects stderr to stdout, =
but there is nothing printed to stderr so it makes no difference. =
However, adding '>nul' (or more explicit, '1>nul') would do the trick, =
i.e. redirecting stdout to the 'nul' file/device. Check the return code =
from system; in my tests it correctly complains if the copy fails for =
some reason (though stupidly enough, the copy command *doesn't* write =
the error message to stderr as it should!).

$x =3D system("copy foo.txt bar.txt >nul");
print "Error: " . ($x >> 8) . "\n";

Another option is to simply use backticks (though I like the alternate =
form using 'qx') and simply disregard the output. Still have to check =
the error code. Also, this is typically not good form (why capture =
potentially a lot of output only to throw it away?).

qx("copy foo.txt bar.txt");
print "Err: " . ($? >> 8) . "\n";

Yet another option is to use the open() call to open a pipe. Similar to =
backticks/qx, but you'll have to read from the pipe (and just discard). =
Saves the memory issue with 'throw away backtick output'.

And why mess with calling an outside program/command when there's tons =
of premade modules that does copying nicely? Or make a small copy =
routine yourself, really just a few lines of code. Etc, etc.

Well, your choice :-)

HTH,

ken1
----- Original Message -----
From: Deane.Rothenmaier [at] walgreens.com
To: activeperl [at] listserv.ActiveState.com
Sent: Tuesday, January 30, 2007 6:07 PM
Subject: redirection failure (may be newbie question,but haven't done =
this before)



Wizards,

...Or it may be just that it's something new for me...

I'm trying to redirect the output of a file copy away from stdout so a =
scheduled script won't leave a big muddy "1 file(s) copied" mess on the =
(non-visible) screen. I checked in the panther book and got the =
suggested redirection command,

*STDOUT =3D *F;

but in my code, I'm still seeing the copied message on my screen. I =
tried the classic "2>&1" redirect embedded in the system call that does =
the actual copying, but that didn't help either. So I must be missing =
something. Here's the relevant code:

# Redirect stdout so "file(s) copied" message goes to log file, not =
screen.
*STDOUT =3D *LOG;

# create values for $edit_file and $save_file here, then...

system( "copy \"$edit_file\" \"$save_file\" /y" );

Is it the system call itself that's keeping me from getting the =
desired results?

Thanks,

Deane Rothenmaier
Systems Architect
Walgreens Corp.
847-914-5150

"On two occasions I have been asked [by members of Parliament], 'Pray, =
Mr. Babbage, if you put into the machine wrong figures, will the right =
answers come out?' I am not able rightly to apprehend the kind of =
confusion of ideas that could provoke such a question." -- Charles =
Babbage


------------------------------------------------------------ -------------=
-----


_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
------=_NextPart_000_2517_01C7449E.A5B89F10
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.5730.11" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2>Deane,</FONT></DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2>The construct =
'2>&1'
won't help here - it redirects stderr to stdout, but there is nothing =
printed to
stderr so it makes no difference. However, adding '>nul' (or more =
explicit,
'1>nul') would do the trick, i.e. redirecting stdout to the 'nul'
file/device. Check the return code from system; in my tests it correctly =

complains if the copy fails for some reason (though stupidly enough, the =
copy
command *doesn't* write the error message to stderr as it =
should!).</FONT></DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2>    =
$x =3D
system("copy foo.txt bar.txt >nul");<BR>    =
print
"Error: " . ($x >> 8) . "\n";</FONT></DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2>Another option is to =
simply use
backticks (though I like the alternate form using 'qx') and simply =
disregard the
output. Still have to check the error code. Also, this is typically not =
good
form (why capture potentially a lot of output only to throw it
away?).</FONT></DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2>    =
qx("copy
foo.txt bar.txt");<BR>    print "Err: " . ($? >> 8) =
..
"\n";</FONT></DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2>Yet another option =
is to use the
open() call to open a pipe. Similar to backticks/qx, but you'll have to =
read
from the pipe (and just discard). Saves the memory issue with 'throw =
away
backtick output'.</FONT></DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2>And why mess with =
calling an
outside program/command when there's tons of premade modules that does =
copying
nicely? Or make a small copy routine yourself, really just a few lines =
of code.
Etc, etc.</FONT></DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2>Well, your choice
:-)</FONT></DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2>HTH,</FONT></DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Lucida Sans Typewriter" size=3D2>ken1</FONT></DIV>
<BLOCKQUOTE
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>
<A title=3DDeane.Rothenmaier [at] walgreens.com
=
href=3D"mailto:Deane.Rothenmaier [at] walgreens.com">Deane.Rothen maier [at] walgree=
ns.com</A>
</DIV>
<DIV style=3D"FONT: 10pt arial"><B>To:</B> <A
title=3Dactiveperl [at] listserv.ActiveState.com
=
href=3D"mailto:activeperl [at] listserv.ActiveState.com">activepe rl [at] listserv.A=
ctiveState.com</A>
</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Tuesday, January 30, 2007 =
6:07
PM</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Subject:</B> redirection failure =
(may be
newbie question,but haven't done this before)</DIV>
<DIV><BR></DIV><BR><FONT face=3Dsans-serif size=3D2>Wizards,</FONT> =
<BR><BR><FONT
face=3Dsans-serif size=3D2>...Or it may be just that it's something =
new for
me...</FONT> <BR><BR><FONT face=3Dsans-serif size=3D2>I'm trying to =
redirect the
output of a file copy away from stdout so a scheduled script won't =
leave a big
muddy "1 file(s) copied" mess on the (non-visible) screen. I checked =
in the
panther book and got the suggested redirection command,</FONT> =
<BR><BR><FONT
face=3Dsans-serif size=3D2>  *STDOUT =3D *F;</FONT> <BR><BR><FONT =

face=3Dsans-serif size=3D2>but in my code, I'm still seeing the copied =
message on
my screen. I tried the classic "2>&1" redirect embedded in the =
system
call that does the actual copying, but that didn't help either. So I =
must be
missing something. Here's the relevant code:</FONT> <BR><BR><FONT
face=3D"Courier New" size=3D2>   # Redirect stdout so =
"file(s) copied"
message goes to log file, not screen.</FONT> <BR><FONT face=3D"Courier =
New"
size=3D2>   *STDOUT =3D *LOG;</FONT> <BR><BR><FONT =
face=3D"Courier New"
size=3D2>   # create values for $edit_file and $save_file =
here,
then...</FONT> <BR><BR><FONT face=3D"Courier New" size=3D2>  =
 system(
"copy \"$edit_file\" \"$save_file\" /y" );</FONT><FONT =
face=3Dsans-serif
size=3D2><BR></FONT><BR><FONT face=3Dsans-serif size=3D2> Is it =
the system call
itself that's keeping me from getting the desired results?</FONT>
<BR><BR><FONT face=3Dsans-serif size=3D2>Thanks,</FONT> <BR><BR><FONT
face=3Dsans-serif size=3D2>Deane Rothenmaier<BR>Systems =
Architect<BR>Walgreens
Corp.<BR>847-914-5150<BR><BR>"On two occasions I have been asked [by =
members
of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong =
figures,
will the right answers come out?' I am not able rightly to apprehend =
the kind
of confusion of ideas that could provoke such a question." -- Charles
Babbage</FONT>
<P>
<HR>

<P></P>_______________________________________________<BR>ActivePerl =
mailing
list<BR>ActivePerl [at] listserv.ActiveState.com<BR>To unsubscribe:
=
http://listserv.ActiveState.com/mailman/mysubs</BLOCKQUOTE></BODY></HTML>=


------=_NextPart_000_2517_01C7449E.A5B89F10--


--===============0232236703==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl [at] listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0232236703==--
ken1 [ Di, 30 Januar 2007 18:44 ] [ ID #1613464 ]
Perl » gmane.comp.lang.perl.active-perl » redirection failure (may be newbie question,

Vorheriges Thema: Re: redirection question -- resolved.
Nächstes Thema: Safe Pipe Opens Supported?