Re: Execute all files and log outputs
- From: Ed Morton <morton@xxxxxxxxxxxxxx>
- Date: Wed, 11 Jul 2007 10:21:48 -0500
Why Tea wrote:
On Jul 11, 12:26 am, Michael Tosch
<eed...@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Why Tea wrote:
I have a directory full of test scripts, how do I execute all of them
in a shell script and log the outputs? The log file should have the
file name of the executable appended with time and date.
E.g. executable.ext > executable_$date_time.ext
Thanks in advance for any suggestion.
/Why Tea
date=`date +%Y-%m-%d-%H:%m`
for file in *
do
test -x "$file" -a -f "$file" || continue
./"$file" > outputs/"$file.$date"
done
It is advantageous to store the $file.$date into another directory.
Thanks Michael. I think we need to exclude the shell script itself,
otherwise it'll forever executing itself. I have added a line to avoid
that. I've also changed the output file name a little.
PN=`basename "$0"`
VER='0.1'
echo >&2 $PN v$VER
echo "$PN v$VER" >&2
date=`date +%y%m%d_%H%m`
# Create outputs directory if it doesn't exit
[ -d outputs ] || mkdir outputs
mkdir -p outputs
if [ ! -d outputs ]; then
echo "$PN: ERROR: outputs directory does not exist." >&2
exit 1
fi
for file in *
do
test -x "$file" -a -f "$file" || continue
if [ $file = "$PN" ]; then
continue
fi
logfile=`echo "$file" | cut -f1 -d.`
logfile="${file%.*}"
[ "$file" != "$PN" ] && [ -f "$file" ] && [ -x "$file" ] &&
./"$file" "$ap" 2>&1 | tee outputs/"$logfile-$date.log"
done
Regards,
Ed.
.
- References:
- Execute all files and log outputs
- From: Why Tea
- Re: Execute all files and log outputs
- From: Michael Tosch
- Re: Execute all files and log outputs
- From: Why Tea
- Execute all files and log outputs
- Prev by Date: AIX vs. Solaris
- Next by Date: Re: saving/restoring function def (bash)
- Previous by thread: Re: Execute all files and log outputs
- Next by thread: saving/restoring function def (bash)
- Index(es):
Relevant Pages
|
|