> >> I guess
> >> exec 3>&1 4>&2 >> "$CSGLOG" 2>/dev/null
> >> will do what you want.
> >>
> >> We could add an option like cg.inverse.error_log_file and use
> >> exec 3>&1 4>&2 >> "$CSGLOG" 2> "$CSG_ERRORLOG"
> >
> > - that might be useful, but maybe you don't put quotes around $CSG_ERRORLOG
> > ?
- For the time being I've simply overridden inverse.sh within my_scripts
directory, replacing the call to enable_logging() with its body altered as
follows (since I cannot override functions_common.sh this way):
===
...
export CSGLOG="$log"
if [[ -f $CSGLOG ]]; then
exec 3>&1 4>&2 >> "$CSGLOG" 2>&1
echo "\n\n#################################"
echo "# Appending to existing logfile #"
echo "#################################\n\n"
msg --color blue "Appending to existing logfile ${CSGLOG##*/}"
else
exec 3>&1 4>&2 >> "$CSGLOG" 2>/dev/null
echo "\n\n#################################"
echo "# Creating new logfile & dumping errors #"
echo "#################################\n\n"
msg "For a more verbose log see: ${CSGLOG##*/}"
fi
===
Works fine, where I can chose to dump errors or not, by either having or not
pre-existing inverse.log (so that if I've got an error, next time this will
show up in the appended inverse.log)
BTW, why do you need "\n\n" in echo strings? - they show up "as is", i.e. no
extra lines around the message (if that was the purpose).
> > otherwise, can it create a file named "/dev/null" instead of dumping the
> > output into the null device? I've tried "inverse.log 2>inverse.err" for
> > $CSGLOG (via tag cg.inverse.log_file in settings.xml) and got the file
> > named "inverse.log 2>inverse.err" (without quotes)
> The quotes are to support spaces in the file names. And your trick
> won't work in bash anyhow:
> $ xxx="1 2> 2"
> $ echo hallo > $xxx
> -bash: $xxx: ambiguous redirect
- what you say, I won't be able to set $CSG_ERRORLOG to "/dev/null" anyway, but
could only split the log into stdout and stderr outputs? not sure if this would
be that useful (if only to ease viewing inverse.log without the tools' progress
reports)
Perhaps, my last question/suggestion here: isn't the starting bit of
enable_logging() supposed to invoke "2>/dev/null" after the name provided in
cg.inverse.log_file tag (maybe when it wasn't found?)? - it doesn't though.
===
local log
if [[ -z $1 ]]; then
log="$(csg_get_property cg.inverse.log_file 2>/dev/null)"
else
log="$1"
fi
===
Anyways one could get around the errors logging by doing "2>/dev/null" only in
the case when cg.inverse.log_file is not found in settings.xml (or has a
specific name, like inverse_no_stderr.log), and "2>&1" otherwise.
Andrey
> >
> > - out of curiosity, do you ever actually use descriptors 3 and/or 4, or is
> > it there just in case for the future uses?
> This is use in the "msg" function:
> $ grep ">&[34]" functions_common.sh
> echo -e "${color}$*${off}" >&4
> echo -e "${color}$*${off}" >&3
> Their use is that inside the script the redirect to log file is
> automatic and not every command needs to redirect with
> "&>" separately.
>
> Christoph
>
> >
> > Thanks
> >
> >> >
> >> > Andrey
> >> >
> >> >> Christoph
> >> >>
> >> >> >
> >> >> > Thanks
> >> >> >
> >> >> > Andrey
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > --
> >> >> > You received this message because you are subscribed to the Google
> >> >> > Groups "votca" group.
> >> >> > To unsubscribe from this group and stop receiving emails from it,
> >> >> > send an email to [email protected].
> >> >> > To post to this group, send email to [email protected].
> >> >> > Visit this group at http://groups.google.com/group/votca.
> >> >> > For more options, visit https://groups.google.com/d/optout.
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> Christoph Junghans
> >> >> Web: http://www.compphys.de
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups "votca" group.
> >> > To unsubscribe from this group and stop receiving emails from it, send
> >> > an email to [email protected].
> >> > To post to this group, send email to [email protected].
> >> > Visit this group at http://groups.google.com/group/votca.
> >> > For more options, visit https://groups.google.com/d/optout.
> >>
> >>
> >>
> >> --
> >> Christoph Junghans
> >> Web: http://www.compphys.de
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "votca" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [email protected].
> > To post to this group, send email to [email protected].
> > Visit this group at http://groups.google.com/group/votca.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Christoph Junghans
> Web: http://www.compphys.de
--
You received this message because you are subscribed to the Google Groups
"votca" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/votca.
For more options, visit https://groups.google.com/d/optout.