|
Answer» When I run this script I get this error: ./fsmon[34]: 10% unexpected `end of __expression'
I went on the sed org sites to review and not sure if I need to use some type of parm to control the end of line or record (not sure at all). As you can see in my script the comments about the PROBLEM are there as well. I have: Linux is ver 9.4 sed ver 4.0.5.1 pdksh ver 5.2.14-21
Can you tell me if the problem is the sed or the typeset, I'm leaning towards sed and the parm I need to use. This is for my learning only - not a business problem.
#!/bin/ksh FSMAX="10" WORKFILE="/tmp/df.work" >$WORKFILE OUTFILE="/tmp/df.outfile" >$OUTFILE THISHOST=`hostname` df -k | tail +2 | egrep -v '/dev/cd[0-9]' | awk '{ print $1, $5, $6}' > $WORKFILE while read FSDEVICE FSVALUE FSMOUNT do #if you com out the typeset and allow the echos to show the values it works. #when the typeset is used the error of: ./fsmon[34]: 10%: unexpected `end of __expression' - is displayed" FSVALUE=$(echo $FSVALUE | sed 's/\%//g') echo $FSVALUE typeset -i FSVALUE echo $FSVALUE if [ $FSVALUE -gt $FSMAX ] then echo "$FSDEVICE mounted on $FSMOUNT is ${FSVALUE}%" >> $OUTFILE fi echo "FSDEVICE= " $FSDEVICE echo "FSVALUE= " $FSVALUE echo "FSMOUNT= " $FSMOUNT
done < $WORKFILE if [[ -a $OUTFILE ]] then echo "\nFull Filesystem(s) on $THISHOST\n" cat $OUTFILE print fi What are you trying to do? Have you tried awk? It has a slightly more useful programming structure... Or how about Perl/PHP?I am re-intruducing myself to scripting on *inx again and this script was a sample from a book. I wanted to see if anyone could assist as to why getting the error: ./fsmon[34]: 10%: unexpected `end of __expression'
Yes awk, perl are other ways to go. Just wanted to get some assist on above.
Thanks Every time I read the texinfo for sed I BREAK out into a cold sweat. All I can say is that if I were trying to do this, I would find a way that bent my mind less.
I don't think there are any sed experts here. GX1_Man may be able to offer some suggestions. Have you access to any other *nix systems to try the script out on? Could be something peculiar to your particular DISTRIBUTION perhaps.
Sorry I can't be of any more help.Nope no other access to *inx systems.
Not a problem, wanted to also start reviewing awk again, used it once in the distant past to port another HP another existing HP system. Had to ensure that the uid/gids and files did not conflict with the destenation system that was already in production.
yep sed bends the mind more then one can 'sed'
Yet to start Perl/PHP. Thanks for the tips.If you go down the PHP route, I'll be able to offer assistance. I'm much more familiar with it than Perl.
|