Date: Thu, 14 Aug 2003 12:11:55 -0500 From: "Charles Howse" <chowse@charter.net> To: <freebsd-questions@freebsd.org> Subject: RE: Using bc in bash script Message-ID: <003001c36287$2a2a7b40$04fea8c0@moe> In-Reply-To: <20030814115313.2707cb21.nospam@hiltonbsd.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> 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: #!/usr/local/bin/bash # Daily Report # Declare variables start_time=`date +%s` time1=`date +%R` month=`date +%b` day=`date +%e` # Cleanup files if [ -a /root/daily.log ] ; then rm /root/daily.log fi # Main report header echo "Daily Report for Larry for" `date '+%A, %B %d %Y'`"." >> /root/daily.log echo "********************************************" >> /root/daily.log echo >> /root/daily.log # OS header echo "Current Operating System" >> /root/daily.log echo "********************************************" >> /root/daily.log uname -sr >> /root/daily.log echo >> /root/daily.log # Uptime Header echo "Uptime" >> /root/daily.log echo "********************************************" >> /root/daily.log uptime >> /root/daily.log echo >> /root/daily.log # Crontab Header echo "Cron Jobs" >> /root/daily.log echo "********************************************" >> /root/daily.log crontab -l >> /root/daily.log echo >> /root/daily.log # Last Header echo "Logins today" >> /root/daily.log echo "********************************************" >> /root/daily.log last | grep "$month $day" >> /root/daily.log echo >> /root/daily.log # Superuser Header echo "Accounts with uid = 0 (Superusers)" >> /root/daily.log echo "********************************************" >> /root/daily.log awk -F: '( $3 == 0 ) { print $1 }' /etc/passwd >> /root/daily.log echo >> /root/daily.log # /etc/passwd Header echo "Accounts that have a valid shell" >> /root/daily.log echo "********************************************" >> /root/daily.log cat /etc/passwd | egrep -v "("nologin"|"uucico"|"\#")" >> /root/daily.log echo >> /root/daily.log # DF Header echo "Disk Free space" >> /root/daily.log echo "********************************************" >> /root/daily.log df -h >> /root/daily.log echo >> /root/daily.log # netstat Header echo "Netstat -an results" >> /root/daily.log echo "********************************************" >> /root/daily.log netstat -an >> /root/daily.log echo >> /root/daily.log # ifconfig echo "Status of network interfaces" >> /root/daily.log echo "********************************************" >> /root/daily.log ifconfig >> /root/daily.log echo >> /root/daily.log # Compute the elapsed time echo "Elapsed Time" >> /root/daily.log echo "********************************************" >> /root/daily.log echo "Report completed at:" `date +%R` >> /root/daily.log echo " Report begun at:" $time1 >> /root/daily.log end_time=`date +%s` et=`echo "scale=5 ; $end_time - $start_time" | bc` echo " Elapsed Time: " $et "seconds" >> /root/daily.log echo >> /root/daily.log # File Modification Date echo "Last modified" >> /root/daily.log echo "********************************************" >> /root/daily.log ls -l /root/bin/daily_report | cut -d" " -f9,10,11 >> /root/daily.log # Mail to Charles cat /root/daily.log | mail -s "Daily Report from Larry" charles
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?003001c36287$2a2a7b40$04fea8c0>