LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 02-25-2009, 08:08 AM   #1
soupbone38
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


#!/bin/ksh
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
D=$d
echo "$D: $s bytes"
fi
done | mailx -s "WARNING: $(hostname):/m02 IS $sys_pct full" admin
echo $i_sys_pct > $HOME/last_pct
fi
 
Old 02-25-2009, 08:42 AM   #2
angel115
Member
 
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 )


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

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

Best regards,
Angel

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

Rep: Reputation: 203Reputation: 203Reputation: 203
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
 
  


Reply


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 09:20 AM
script question therealbxp Programming 5 08-07-2005 04:28 AM
Script question yoderp Linux - General 8 07-06-2005 08:57 AM
Script Question blas Linux - General 5 02-14-2004 12:48 AM
Script question? Nicksan Linux - Newbie 3 06-03-2003 09:12 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:29 AM.

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