Re: Execute all files and log outputs



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.
.



Relevant Pages

  • Windows Credentialing Security Problem
    ... think this is an IIS security issue, since I'm able to access the page I'm ... My web site has a virtual directory named FPSNowAuth. ... code executing in the context of a page request should be executing in ... the log file snippet. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Windows Credentialing Security Problem
    ... think this is an IIS security issue, since I'm able to access the page I'm ... My web site has a virtual directory named FPSNowAuth. ... code executing in the context of a page request should be executing in ... the log file snippet. ...
    (microsoft.public.inetserver.iis)
  • Windows Credentialing Security Problem
    ... think this is an IIS security issue, since I'm able to access the page I'm ... My web site has a virtual directory named FPSNowAuth. ... code executing in the context of a page request should be executing in ... the log file snippet. ...
    (microsoft.public.windows.server.security)
  • Re: Concurrent Batch/queue entries
    ... concurrent jobs that may be executing in that queue. ... If you have a log file for the executing job, wait one minute for the system ... usually means that it is waiting for I/O to complete. ...
    (comp.os.vms)
  • Re: Not entirely OT: RSHELL to Solaris
    ... > Andrew Harrison SUNUK Consultancy wrote: ... remotely execute the shell script on the Sun from ... OpenVMS form inside something like DCL. ... the OpenVMS user executing the remote command. ...
    (comp.os.vms)