Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-25-2009, 09:08 AM   #1
LQ Newbie
Registered: Feb 2009
Posts: 8

Rep: Reputation: 0
Script Question

Im new to scripting and keep getting this message that i don't know how to fix. Could someone tell me what's wrong with this script?

[: 70: unexpected operator/operand

set -x
touch $HOME/last_pct
let max_pct=70
let max_diff=10
read last_pct < $HOME/last_pct
let i_last_pct=${last_pct:-0}
#sys_pct=$(df -k | grep "/m02" | awk '{print $5}')
sys_pct=$(df -k /u02 | grep "/m02" | awk '{print $5}')
i_sys_pct=${sys_pct%\%} # strip % sign
let i_pct_diff=$i_sys_pct-$i_last_pct
if [ $i_sys_pct -gt $max_pct ] && [ $i_pct_diff -ge $max_diff ];then
typeset -L30 D
du -sk /m02/admin/* |
while read s d;do
if [ $s -gt 500000 ];then
echo "$D: $s bytes"
done | mailx -s "WARNING: $(hostname):/m02 IS $sys_pct full" admin
echo $i_sys_pct > $HOME/last_pct
Old 02-25-2009, 09:42 AM   #2
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 536

Rep: Reputation: 79
Hi soupbone38,

If I may give you a quick tips first:
- Add the comment to your scripts help a lot when you read it again. (and it will help me as well to understand what you are trying to do )

while read s d;do
if [ $s -gt 500000 ];then
echo "$D: $s bytes"
Try to "secure" your variable by {}

while read s d;do
if [ ${s} -gt 500000 ];then
echo "${D}: ${s} bytes"
Apply the above to all variables.

Best regards,

Last edited by angel115; 02-25-2009 at 09:47 AM.
Old 02-25-2009, 10:16 AM   #3
Senior Member
Registered: Mar 2004
Location: england
Distribution: Debian, Mint, Puppy, Raspbian
Posts: 3,435

Rep: Reputation: 204Reputation: 204Reputation: 204
well, it's line 70 for a start.
probably something like this:

[ $s -gt 500000 ]
which should always be quoted:

[ "$s" -gt 50000 ]

maybe $s is blank


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Script question pvpnguyen Programming 4 03-03-2008 10:20 AM
script question therealbxp Programming 5 08-07-2005 05:28 AM
Script question yoderp Linux - General 8 07-06-2005 09:57 AM
Script Question blas Linux - General 5 02-14-2004 01:48 AM
Script question? Nicksan Linux - Newbie 3 06-03-2003 10:12 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:11 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration