09-21-07 12:21 AM
On Thu, 20 Sep 2007 16:20:30 -0700, explor wrote:
> On Sep 20, 3:48 pm, Kenan Kalajdzic <ke...@cced.ba> wrote:
>
> Thanks..but i still have an issue
>
> for HOST in 7 8 9 10 11 12 13
> do
> eval LOGGED_USERS_${HOST}=$(ssh mailhost${HOST} "netstat -an | g
rep
> ESTABLISHED | grep ".143" |wc -l | tr -d ' '") done
>
> print "Users Logged in Mailt7: ${LOGGED_USERS_$HOST}"
>
> ./imap_connection.sh[24]: "Users Logged in Mailt 7: ${LOGGED_USE
RS_
> $HOST}": bad substitution
Well, the HOST variable is probably not set on line 24 in the way that
you expect.
However the main problem is that you have the wrong syntax. You need
eval print "Users Logged in Mailt7: \${LOGGED_USERS_$HOST}"
You may be able to avoid these eval statements if you can use an array
instead. Also you can probably use grep to count, rather than using wc
and tr, and you probably want to quote the "." in the pattern to grep
or else use fgrep, or else use a colon which is the actual character I
think you want to match.
CMD="netstat -tn | grep -c ':143.*ESTABLISHED'"
for HOST in 7 8 9 10 11 12 13
do
LOGGED_USERS[${HOST}]=$(ssh mailhost${HOST} "$CMD" )
print "Users Logged in Mailt7: ${LOGGED_USERS[$HOST]}"
done
[ Post a follow-up to this message ]
|