sunhux
asked on
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
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
What is on line 5 of pattsigupd.sh?
ASKER
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 ]]
#!/bin/bash
#
# pull updates from central server
#
rndnum=$[ 1 + $[ RANDOM % 100 ]]
sleep $rndnum
#
So line 5 is :
rndnum=$[ 1 + $[ RANDOM % 100 ]]
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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:
https://www.experts-exchange.com/questions/28703371/Need-Shell-script-to-parse-thru-suitable-filesystems-files-folders-for-AV-scanning.html
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:
https://www.experts-exchange.com/questions/28703371/Need-Shell-script-to-parse-thru-suitable-filesystems-files-folders-for-AV-scanning.html
ASKER
rndnum=$(( 1 + RANDOM % 100 ))
works fine
works fine