SOLVED - Using bc in Bash script

2003-08-14 Thread Charles Howse
Got it going. Instead of running daily_report from cron, I will now run the following: - #!/usr/local/bin/bash # Time and run the Daily_report \time -ho /root/tmp.time ~/bin/daily_report cat /root/tmp.time | cut -f 2 | cut

RE: Using bc in bash script

2003-08-14 Thread Charles Howse
OK, I've been playing with the time command to get the elapsed time of my daily_report script reported in 2 decimal places. If I do: # \time -ha ~/daily.log ~/bin/daily_report (append output of time to ~/daily.log) I get: Time: /root/daily.log permission denied (time output) If I do: # chmod 666

Re: Using bc in bash script

2003-08-14 Thread Jez Hancock
On Thu, Aug 14, 2003 at 12:23:34PM -0500, Stephen Hilton wrote: > On Thu, 14 Aug 2003 12:11:55 -0500 > "Charles Howse" <[EMAIL PROTECTED]> wrote: > > > > Charles, > > > > > > This will set bc precision to 5 decimal places: > > > > > > et=`echo "scale=5 ; $end_time - $start_time" | bc` > > > > O

RE: Using bc in bash script

2003-08-14 Thread Charles Howse
> > Can I refine it to give me something like: .784 seconds? > > Use "bc -l" instead of bc. That should do it. No, that still gives 0 seconds. I think this whole thing is dependent on the fact that `date +%s` reports integers. I'm still interested in something like .874 seconds, but for the ti

RE: Using bc in bash script

2003-08-14 Thread Alexander Haderer
At 11:45 14.08.2003 -0500, Charles Howse wrote: > > Can I refine it to give me something like: .784 seconds? > > Use "bc -l" instead of bc. That should do it. No, that still gives 0 seconds. I think this whole thing is dependent on the fact that `date +%s` reports integers. I'm still interested i

RE: Using bc in bash script

2003-08-14 Thread Charles Howse
I received this msg a short time ago: Antigen for Exchange found daily_report.sh matching =*.sh file filter. The file is currently Removed. The message, "RE: Using bc in bash script", was sent from Charles Howse and was discovered in IMC Queues\Inbound located at mcglinchey/NewOr

Re: Using bc in bash script

2003-08-14 Thread Alexander Haderer
At 11:35 14.08.2003 -0500, Kirk Strauser wrote: At 2003-08-14T16:08:21Z, "Charles Howse" <[EMAIL PROTECTED]> writes: > Can I refine it to give me something like: .784 seconds? Use "bc -l" instead of bc. That should do it. Yes, but not in the context mentioned before: > > > Start_time=`date +%s`

Using bc in bash script

2003-08-14 Thread Charles Howse
Hello List, I've migrated from Redhat Linux 9 to FreeBSD 4.8-RELEASE, character mode - no gui. I'm trying to calculate the number of seconds between $start_time and $end_time in a bash script. Start_time=`date +%s` # Seconds past midnight at start of script [ do lots of stuff ] End_time=`date +%

Re: Using bc in bash script

2003-08-14 Thread Jez Hancock
On Thu, Aug 14, 2003 at 10:46:45AM -0500, Charles Howse wrote: > Hello List, > > I've migrated from Redhat Linux 9 to FreeBSD 4.8-RELEASE, character mode > - no gui. > > I'm trying to calculate the number of seconds between $start_time and > $end_time in a bash script. > > Start_time=`date +%s`

Re: Using bc in bash script

2003-08-14 Thread Stephen Hilton
On Thu, 14 Aug 2003 11:08:21 -0500 "Charles Howse" <[EMAIL PROTECTED]> wrote: > > On Thu, Aug 14, 2003 at 10:46:45AM -0500, Charles Howse wrote: > > > Hello List, > > > > > > I've migrated from Redhat Linux 9 to FreeBSD 4.8-RELEASE, > > character mode > > > - no gui. > > > > > > I'm trying to c

RE: Using bc in bash script

2003-08-14 Thread Charles Howse
> > The precision is in hundredths of a second as I understand it from > > playing with time(!): > > > > #!/bin/sh > > time_file=tmp.time > > time="time -a -o $time_file" > > $time cat /var/log/messages >/dev/null 2>&1 > > $time cat /var/log/maillog >/dev/null 2>&1 > > awk '{sum+=$1}END{print sum}

Re: Using bc in bash script

2003-08-14 Thread Stephen Hilton
On Thu, 14 Aug 2003 18:34:25 +0100 Jez Hancock <[EMAIL PROTECTED]> wrote: > On Thu, Aug 14, 2003 at 12:23:34PM -0500, Stephen Hilton wrote: > > On Thu, 14 Aug 2003 12:11:55 -0500 > > "Charles Howse" <[EMAIL PROTECTED]> wrote: > > > > > > Charles, > > > > > > > > This will set bc precision to 5 d

Re: Using bc in bash script

2003-08-14 Thread Kirk Strauser
At 2003-08-14T16:08:21Z, "Charles Howse" <[EMAIL PROTECTED]> writes: > Can I refine it to give me something like: .784 seconds? Use "bc -l" instead of bc. That should do it. -- Kirk Strauser pgp0.pgp Description: PGP signature

Re: Using bc in bash script

2003-08-14 Thread Stephen Hilton
On Thu, 14 Aug 2003 12:11:55 -0500 "Charles Howse" <[EMAIL PROTECTED]> wrote: > > Charles, > > > > This will set bc precision to 5 decimal places: > > > > et=`echo "scale=5 ; $end_time - $start_time" | bc` > > Ohhh, I was really hoping on that one...but no, it still reports 0 > seconds. Sorry

Re: Using bc in bash script

2003-08-14 Thread Joshua Oreman
On Thu, Aug 14, 2003 at 12:58:01PM -0500 or thereabouts, Stephen Hilton wrote: > On Thu, 14 Aug 2003 18:34:25 +0100 > Jez Hancock <[EMAIL PROTECTED]> wrote: > > > On Thu, Aug 14, 2003 at 12:23:34PM -0500, Stephen Hilton wrote: > > > On Thu, 14 Aug 2003 12:11:55 -0500 > > > "Charles Howse" <[EMAIL

Re: Using bc in bash script

2003-08-14 Thread Kirk Strauser
At 2003-08-14T17:58:01Z, Stephen Hilton <[EMAIL PROTECTED]> writes: > I still am wondering why the date command does not have a format string > for seconds (down to 100th's) like "+%ss" and also why the time command > stops at 100th's when other programs resolve time to 5 or 6 decimal places? My

RE: Using bc in bash script

2003-08-14 Thread Charles Howse
> > > Sorry I jumped the gun there, the scale is needed for > this to work Not a problem, thanks for working with me! > > The precision is in hundredths of a second as I understand it from > > playing with time(!): > > > > #!/bin/sh > > time_file=tmp.time > > time="time -a -o $time_file" > > $

Re: Using bc in bash script

2003-08-14 Thread Kirk Strauser
At 2003-08-14T16:45:56Z, "Charles Howse" <[EMAIL PROTECTED]> writes: > I think this whole thing is dependent on the fact that `date +%s` reports > integers. As his daughter says, "DUUUH"! I only saw the $end_time and $start_time variables, and not their origins. I'll go back to lurking now.

Re: Using bc in bash script

2003-08-14 Thread Jez Hancock
On Thu, Aug 14, 2003 at 11:08:21AM -0500, Charles Howse wrote: > > On Thu, Aug 14, 2003 at 10:46:45AM -0500, Charles Howse wrote: > > > Hello List, > > > > > > I've migrated from Redhat Linux 9 to FreeBSD 4.8-RELEASE, > > character mode > > > - no gui. > > > > > > I'm trying to calculate the num

RE: Using bc in bash script

2003-08-14 Thread Charles Howse
> Charles, > > This will set bc precision to 5 decimal places: > > et=`echo "scale=5 ; $end_time - $start_time" | bc` Ohhh, I was really hoping on that one...but no, it still reports 0 seconds. Maybe there's something in the script itself that's messing this up. Here is the entire script: #!/

Re: Using bc in bash script

2003-08-14 Thread Richard Tobin
> I'm trying to calculate the number of seconds between $start_time and > $end_time in a bash script. Bash has built-in integer arithmetic: et=$[End_time - Start_time] -- Richard ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/lis

Re: Using bc in bash script

2003-08-14 Thread Dan Nelson
In the last episode (Aug 14), Richard Tobin said: > > I'm trying to calculate the number of seconds between $start_time and > > $end_time in a bash script. > > Bash has built-in integer arithmetic: > > et=$[End_time - Start_time] Most bourne-based shells have arithmetic evaluation. For portab

RE: Using bc in bash script

2003-08-14 Thread Charles Howse
> On Thu, Aug 14, 2003 at 10:46:45AM -0500, Charles Howse wrote: > > Hello List, > > > > I've migrated from Redhat Linux 9 to FreeBSD 4.8-RELEASE, > character mode > > - no gui. > > > > I'm trying to calculate the number of seconds between > $start_time and > > $end_time in a bash script. > >