in reply to Re^2: how i capture a script error to a file ?
in thread how i capture a script error to a file ?

want to capture my script compilation erros ( or other errors ) to a log file

To capture compilation errors, redirect the STDERR of the invoking shell to the file as in my previous post:

$ perl script.pl 2>log.err

This also captures runtime errors thrown out STDERR. If you want to only capture fatal runtime errors, you might handle these through a DIE handler. However, this handler isn't setup if the compilation fails in the first place.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^4: how i capture a script error to a file ?
by gabrielsousa (Sexton) on Apr 27, 2017 at 13:41 UTC


    ok, but i do it on script ? without using > stderr on bash

      ok, but i do it on script ?

      What environment does "on script" connote? The program in question is invoked by "some something", and that "some something"'s STDERR must be redirected to the error log. The notation I gave is for bash (and sh, korn shell, zsh and others). Check the documentation of that "some something" about how to redirect its STDERR.

      If that "some something" is another instance of perl, see open about how to redirect STDERR. You might want to localize that redirection.

      perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'