Help troubleshoot script with RANDOM variable

Whether I use the divide signs  /  or  %   it will keep giving me that "usage: sleep time"
error.   echo $randnm  will not echo anything.

I was sure it worked previously but all of a sudden it doesn't anymore

#!/bin/bash
#
randnm=$[ 1 + $[ RANDOM / 100 ]]
pattsigupd.sh[5]: 1:  not found
## rndnum=$[ 1 + $[ RANDOM % 100 ]]
sleep $randnm
usage: sleep time
#
echo $randnm
sunhuxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
What is on line 5 of pattsigupd.sh?
0
sunhuxAuthor Commented:
This error 1st appear on the original script below (1st 6-7 lines shown below):

#!/bin/bash
#
# pull updates from central server
#
rndnum=$[ 1 + $[ RANDOM % 100 ]]
sleep $rndnum
#


So line 5 is :
rndnum=$[ 1 + $[ RANDOM % 100 ]]
0
ozoCommented:
Should work in bash.
Perhaps you have an old version?
Does
rndnum=$(( 1 + RANDOM % 100 ))
work any better?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

MikeOM_DBACommented:
Or just:

(( randnm = 1 + RANDOM / 100 ))

Open in new window

0
sunhuxAuthor Commented:
Thanks, I'll test it out next Tue when back to office.


In the meantime, I have a new requirement in another link below;  if you can have a
look at it & provide sort of Shell or Perl script to be run in Solaris 10, will appreciate it:

http://www.experts-exchange.com/questions/28703371/Need-Shell-script-to-parse-thru-suitable-filesystems-files-folders-for-AV-scanning.html
0
sunhuxAuthor Commented:
rndnum=$(( 1 + RANDOM % 100 ))

works fine
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.