Date: Sun, 08 Aug 2004 11:37:01 -0400 From: "Hakim Z. Singhji" <hakim.singhji@earthlink.net> To: David Fleck <david.fleck@mchsi.com> Cc: questions@freebsd.org Subject: Re: Help Debugging Kshell Script??? Message-ID: <4116489D.2010905@earthlink.net> In-Reply-To: <20040808072043.S10021@grond.sourballs.org> References: <411318A8.4080100@earthlink.net> <20040806161222.O275@grond.sourballs.org> <4115842C.2090907@earthlink.net> <20040808072043.S10021@grond.sourballs.org>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a cryptographically signed message in MIME format. --------------ms090907050800000406060209 Content-Type: multipart/mixed; boundary="------------090509020004050901070703" This is a multi-part message in MIME format. --------------090509020004050901070703 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 David, I appologize you are correct the script I sent you is a version of the same script that I am working on for an AIX machine. Attached is an unencrypted version of the script for System V: BSD/Linux machines. This is the error it is giving me and I'm not sure why I am getting this error? ######################################################################## [hakim@redgate sys_admin]$ ./swap_mon.ksh~ \nSwap Space Report for redgate.ath.cx\n Sun Aug 8 00:03:48 EDT 2004 (standard_in) 3: illegal character: O (standard_in) 3: parse error (standard_in) 3: illegal character: O (standard_in) 3: parse error \nTotal Amount of Swap Space:\t494MB Total KB of Swap Space Used:\t23MB Total KB of Swap Space Free:\t471MB \nPercent of Swap Space Used:\t4.6500% \nPercent of Swap Space Free:\t95.3400% \n ######################################################################### I need some help figuring out why bc is giving me such a hard time. I'm almost positive my syntax is correct. This is where I think the problem begins (and possibly ends) in the script: ######################################################################### do # Use the bc utility in a here document to calculate the percentage of # free and used swap space PERCENT_USED=$(bc <<EOF scale=4 ($SW_USED / $SW_TOTAL) * 100 EOF ) PERCENT_FREE=$(bc <<EOF scale=4 ($SW_FREE / $SW_TOTAL) * 100 EOF ) ########################################################################## Thanks for your help in advance. HZS David Fleck wrote: | Unfortunately, I think the script you attached has been mangled in some | way or other; it appears to be missing the end of the 'paging_mon' | function, as well as whatever code invokes that function (and the | swap_mon function as well). If I try to run it, I get: | | dcf>$ ./swap_mon.ksh | \nSwap Space Report for grond.sourballs.org\n | Sun Aug 8 07:31:26 CDT 2004 | ./swap_mon.ksh: line 85: funtion: command not found | ./swap_mon.ksh: line 135: syntax error: unexpected end of file | | if I fix the typo (funtion -> function) I just get the 'unexpected EOF' | error. | | Both my 4.9 and 5.2.1 systems have /usr/bin/bc, so I assume it is part | of the base install. However, neither system has 'lsps', which appears | to be an AIX command. | | | -- | David Fleck | david.fleck@mchsi.com | | _______________________________________________ | freebsd-questions@freebsd.org mailing list | http://lists.freebsd.org/mailman/listinfo/freebsd-questions | To unsubscribe, send any mail to | "freebsd-questions-unsubscribe@freebsd.org" | -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFBFkiclT9WV6TztkoRAngzAJ4jtRcnE5ZkANyZOM9ORxb+scnMNACeJFVf JzNrpFMIjSw0NfpxOgyT13U= =sXLe -----END PGP SIGNATURE----- --------------090509020004050901070703 Content-Type: text/plain; name="swap_mon1.ksh" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="swap_mon1.ksh" ############################################################################## #! /usr/bin/ksh ############################################################################### # CREATED_BY: Hakim Z. Singhji ############################################################################### # SCRIPT: swap_mon.zsh ############################################################################### # DATE: 8/4/04 ############################################################################### # VERSION: 0.1 ############################################################################### # PLATFORM: Linux Only ############################################################################### # PURPOSE: This shell script is used to produce a report of the system's swap # space statistics including: Total paging space in MB, MB of free # paging space, MB of used pagine space, % of paging space used and # % of paging space free ############################################################################### # REV LIST: # set -x # Uncomment to debug this shell script # set -n # Uncomment to check command syntax without any execution ############################################################################### ############################# DEFINE VARIABLES HERE ########################### THISHOST=$(hostname) # Host name of this machine PC_LIMIT=65 # Upper limit of Swap space percentage before # notification ############################################################################### ############################# INITIALIZE THE REPORT ########################### echo "\nSwap Space Report for $THISHOST\n" date ############################################################################### ############################# CAPTURE AND PROCESS DATE ######################## free -m | grep -i swap | while read junk SW_TOTAL SW_USED SW_FREE do # Use the bc utility in a here document to calculate the percentage of # free and used swap space PERCENT_USED=$(bc<<EOF scale=4 ($SW_USED / $SW_TOTAL) * 100 EOF ) PERCENT_FREE=$(bc<<EOF ($SW_FREE / $SW_TOTAL) * 100 EOF ) # Produce the rest of the paging space report: echo "\nTotal Amount of Swap Space:\t${SW_TOTAL}MB" echo "Total KB of Swap Space Used:\t${SW_USED}MB" echo "Total KB of Swap Space Free:\t${SW_FREE}MB" echo "\nPercent of Swap Space Used:\t${PERCENT_USED}%" echo "\nPercent of Swap Space Free:\t${PERCENT_FREE}%" # Grab the integer portion of the percent used to test for # the over limit threshold INT_PERCENT_USED=$(echo $PERCENT_USED | cut -d. -f1) if (( PC_LIMIT <= INT_PERCENT_USED )) then # Swap space limit has exceeded th threshold, send # notification tput smso # TURN ON REVERSE VIDEO!!!!!!!!! echo "\n\nWARNING: Paging Space has Exceeded the ${PC_LIMIT}% Upper Limit!\n" tput rmso # TURN OFF REVERSE VIDEO!!!!!!!!!!!!!! fi done echo "\n" ############################################################################### #BELOW SEE THE ERROR MESSAGE DUE TO SHELL CONVERSION PROBLEMS # [hakim@redgate scripts]$ ./swap_mon.ksh # \nSwap Space Report for redgate.ath.cx\n # Fri Aug 6 00:04:14 EDT 2004 # ./swap_mon.ksh: line 1: bc: command not found # ./swap_mon.ksh: line 1: bc: command not found # \nTotal Amount of Swap Space:\t494MB # Total KB of Swap Space Used:\t0MB # Total KB of Swap Space Free:\t494MB # \nPercent of Swap Space Used:\t% # \nPercent of Swap Space Free:\t% # \n ############################################################################### ############################# END OF FILE ##################################### --------------090509020004050901070703-- --------------ms090907050800000406060209 Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIJQzCC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gbY N81IQ6ELBGuBUEs+TgoAAAAAAAA= --------------ms090907050800000406060209--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4116489D.2010905>