Networking Forums

Networking Forums > Computer Networking > Linux Networking > Run script problem

Reply
Thread Tools Display Modes

Run script problem

 
 
mia456789@yahoo.com.hk
Guest
Posts: n/a

 
      01-05-2005, 02:14 PM
I hv a script as below , it work fine to run at unix box , but fail to
run at linux , could suggest how to modify it to make it work fine
at linux , very thx if anyone can help.

my script is as below , could suggest how can I modify it to make it
work ? thx


#!/bin/sh

PATH=$PATH:/usr/bin:/usr/sbin:/usr/contrib/bin
TIMEOUT=40
EXCEPTIONLIST=~ckyoung/exception.lst
touch $EXCEPTIONLIST

kill_pid()
{
PID=$1
kill -9 $PID
}

echo "User:Activity:PID:Status"
who -u | while read line
do
time=$(echo $line | awk '{print $6}')
pid=$(echo $line | awk '{print $7}')
user=$(echo $line | awk '{print $1}')

grep -q "^${user}:" $EXCEPTIONLIST
if [ $? != 0 ]
then
if [ "$time" = "old" ]
then
(( time = $TIMEOUT + 1 ))
else
echo $time |grep -q "\."
if [ $? != 0 ]
then
time=$(echo $time|awk '{FS=":";print $1*60+$2}')
else
time=0
fi
fi
fi
#echo $time
if [ $time -gt $TIMEOUT ]
then
echo "$user:$time:$pid:Killed"

# Uncomment to do kill that PID
kill_pid $pid
else
echo "$user:$time:$pid:Untouched"
fi
done

the error is
../kill_idle: line 38: [: 00:03: integer expression expected , where
line 38 is "if [ $time -gt $TIMEOUT ]" ,
 
Reply With Quote
 
 
 
 
Davide Bianchi
Guest
Posts: n/a

 
      01-05-2005, 02:22 PM
On 2005-01-05, (E-Mail Removed) <(E-Mail Removed)> wrote:
> the error is
> ./kill_idle: line 38: [: 00:03: integer expression expected , where
> line 38 is "if [ $time -gt $TIMEOUT ]" ,


Yes, well, obviously "00:03" isn't recognized as a number. You'll have
to fix the way you get '$time'.

Davide

--
Some drink from the Fountain of Knowledge. Others just gargle. -- Dave Aronson
And some pee in it. -- moc.oohay
 
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Logon Script problem tony@i-cable Windows Networking 2 06-22-2006 10:12 AM
Proxy Script problem...? Raymond Wong Windows Networking 1 05-09-2005 11:53 AM
Problem with Cron script in mailserver Doug Laidlaw Linux Networking 2 07-17-2004 02:08 PM
VPN Logon script problem Dan Windows Networking 4 07-09-2004 05:25 PM
rc.local firewall script problem Eric Linux Networking 3 12-20-2003 08:34 PM



1 2 3 4 5 6 7 8 9 10 11