From owner-freebsd-questions@FreeBSD.ORG Sun Aug 8 15:36:38 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E439716A4CE for ; Sun, 8 Aug 2004 15:36:37 +0000 (GMT) Received: from asmtp-a063f29.pas.sa.earthlink.net (asmtp-a063f29.pas.sa.earthlink.net [207.217.120.131]) by mx1.FreeBSD.org (Postfix) with ESMTP id BCCAE43D3F for ; Sun, 8 Aug 2004 15:36:37 +0000 (GMT) (envelope-from hakim.singhji@earthlink.net) Received: from user-0cceq8c.cable.mindspring.com ([24.199.105.12] helo=earthlink.net)(TLSv1:AES256-SHA:256) (Exim 4.34) id 1Btpiu-0004tU-QE; Sun, 08 Aug 2004 08:36:37 -0700 Message-ID: <4116489D.2010905@earthlink.net> Date: Sun, 08 Aug 2004 11:37:01 -0400 From: "Hakim Z. Singhji" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040115 X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Fleck References: <411318A8.4080100@earthlink.net> <20040806161222.O275@grond.sourballs.org> <4115842C.2090907@earthlink.net> <20040808072043.S10021@grond.sourballs.org> In-Reply-To: <20040808072043.S10021@grond.sourballs.org> X-Enigmail-Version: 0.83.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg=sha1; boundary="------------ms090907050800000406060209" X-ELNK-Trace: 59e746354e49a56ad5e26e230a8c4dea74bf435c0eb9d47882885355c204f66bb2c0915ad80e4ddf088be428fcecda03350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 24.199.105.12 cc: questions@freebsd.org Subject: Re: Help Debugging Kshell Script??? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Aug 2004 15:36:38 -0000 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 <$ ./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<