On Thursday 20 April 2006 23:31, John W. Krahn wrote:
> Bjørge Solli wrote:
> > On Thursday 20 April 2006 12:01, John W. Krahn wrote:
> >>Bjørge Solli wrote:
> >>>I have this as a part of my script:
> >>>
> >>>    $ncfile = `ls -1 $mersea_cat | head -1`;
> >>>    print $ncfile;
> >>>
> >>>It prints the desired first file in $mersea_cat, but _before_ that the
> >>> ls command prints an errormessage to stderr:
> >>>
> >>>ls: write error: Broken pipe
> >>
> >>Why not just do it in Perl without shelling out to use ls and head:
> >>
> >>my $ncfile = substr glob( "$mersea_cat/*" ), length( $mersea_cat ) + 1;
> >
> > Ah. Of course...
> >
> > Since $mersea_cat = /path/to/filenamestart* to represent all the files
> > starting with filenamestart, this worked fine:
> >
> > $ncfile = glob($mersea_cat); #path and filename is ok.
> >
> > Thankyou very much.
> >
> > Still wondering why that errormessage was printed though, but not very
> > important any more.
>
> It is a shell error.  Perhaps this will explain:
>
> http://groups.google.com/group/comp.unix.shell/browse_frm/thread/db662cdf6c
>43cbab/27662922386b59b3?lnk=st&q=broken+pipe+group%3Acomp.unix.shell&rnum=10
>&hl=en#27662922386b59b3

Brilliant, thanks!

So it's because a cronjob is run in sh and my shell when running interactively 
is bash. Should have thought about that:-)

-- 
Bjørge Solli - Office:+47 55205847 http://www.nersc.no
Nansen Environmental and Remote Sensing Center - Bergen, Norway
Dept.: Mohn-Sverdrup Center for Global Ocean Studies 
       and Operational Oceanography

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to