and its working perfectly in 2.05b.0(1) bash called with ksh and bash
But in 3.2.25(1) version of bash only the first line of status.txt passes. Then (on the second line of the file status.txt) i get this error : arithmetic syntax error
on this line vkupno=$(( vkupno + kolku )). Can someone pls help. What should i change in the script to work in new bash.
Thanks in advance
P.S. status.txt consists of lines :
sometext 4
another text 12
and so on
You do not initialize a variable.
The "cat" should also not be there - it is called UUOC - useless use of cat - a waste of resources. There are also some other oddities in there - like using two awk calls each writing to a file, instead of just reading in the two variables on the while line.
If I understand your code I would write this:
I left in the echo statements, they look more like debug statements....
Here is the whole script:
#!/bin/bash
vkupno=0
while read txt num
do
echo $txt
echo $num
let vkupno=( $vkupno + $num )
echo $vkupno
if [ $(( num )) -lt 5 ]; then
STATUS="OK"
fi
if [ $(( num )) -ge 5 ]; then
STATUS="WORRIED"
fi
if [ $(( num )) -ge 10 ]; then
STATUS="PANIC"
fi
done < status.txt
echo $vkupno
if [ $(( vkupno )) -lt 10 ]; then
STATUS="OK"
fi
if [ $(( vkupno )) -ge 10 ]; then
STATUS="WORRIED"
fi
if [ $(( vkupno )) -ge 20 ]; then
STATUS="PANIC"
fi
Whatever i write on older bash it's working, and on this newer version nothing. I'm still getting the arithmetic error, even on if [ $(( num )) -lt 5 ]; then lines.
Anyway thanks a lot guys. If the script won't work at least i learned to write little more nicer code.
But if You have any ideas please....
Last edited by Ruzeil; 06-23-2009 at 06:22 AM..
Reason: syntax errors
I did find a few posts about syntax error issues with bash 3.2.x versions. A little more research is needed though. You didn't by chance edit the file on a Windows system? This would have left \n\r on the lines and cause errors. What version of RedHat are you running? Have you checked for updates to the bash rpm for that release?
Hi all,
-------------------------
Linux OS Version/Release:
-------------------------
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Linux <hostname> 2.6.18-194.8.1.el5 #1 SMP Wed Jun 23 10:52:51 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
I have a server that hosts 30+ Oracle... (1 Reply)
I'm am working with a Red Hat Enterprise 3 server.
This is a dedicated server that is supposedly dedicated to one domain, but I have been tasked with trying to figure out if there are files on this system that are being accessed by other IP's.
Does anyone know if how I would go about finding... (0 Replies)
hi
i need to put the full path of every executable i need to put on my script. on the testing you don't need it but if it's running from cron you need to put the full path of the executable or another script.
what's the work around for this?
Thanks. (1 Reply)
i would like to make a shell script (red hat 9 cmd line only)
to telnet to my local isp's webmail server on port 25 and send it commands
such as helo :) help would be much appreciated, and i found no posts similar that answered my question... the closest i've gotten to an answer from about 8... (3 Replies)
hello.
I would be greatfull if someone could tell me how will i see what dns server and gateway my red hat server uses.
I tryied to find out by typing ifconfig command but i got :
-bash: ifconfig: command not found , although man ifonconfig gives output with info about using that command.
Is... (3 Replies)
please help me how to install softwares in linux.i have a ethernet internet connection.i try to open the site on LAN to download internet client.but i cannot as our lan supports only internet explorer....i downloaded the linux client by booting thru XP......but i cannot c my NTFS partition thru... (0 Replies)
I just installed red hat 7.2 on my laptop. it's dual booted with xp and red hat. when i boot in to linux it boots up to the screen to ask me my name and pass....i put in root and my password. after this it goes to a blue screen and sits there. the after about 2 minutes it comes up with a fatal... (1 Reply)