|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
My script work on Linux but not work in sunos.
My script work on Linux but not work in sun os. my script. Code:
logFiles="sentLog1.log sentLog2.log"
intial_time="0 0"
logLocation="/usr/local/tomcat/logs/"
sleepTime=600
failMessage=":: $(tput bold)Log not update$(tput rmso) = "
successMessage="OK"
arr=($logFiles)
time_arr=($intial_time)
arrlen=${#arr[@]}
arrcount=()
date
for count=0; count<arrlen; count++ ; do
arrcount[$count]=`ls -l $logLocation${arr[$count]} |awk '{print $5}'`
echo "${arr[$count]} Original size :: ${arrcount[$count]}"
done
echo
while [ "e" == "e" ] ; do
sleep $sleepTime
date
for ((count=0; count<arrlen; count++)) ; do
nc=`ls -l $logLocation${arr[$count]} |awk '{print $5}'`
echo -n "${arr[$count]} "
if [ $nc == ${arrcount[$count]} ] ; then
time_arr[$count]=`echo ${time_arr[$count]} + 10 | bc`
echo $failMessage " " ${time_arr[$count]} " Minute."
else
arrcount[$count]=$nc
echo $successMessage
time_arr[$count]=0
fi
done
echo
echo
echo
echo
donerun on linux it ok. but run on sun os it not ok. output of sun os. Code:
Wed Jan 30 17:08:28 USA 2013
./MonSellVASMDB.sh: line 18: syntax error near unexpected token `(('
./MonSellVASMDB.sh: line 18: `for ((count=0; count<arrlen; count++)) ; do' |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Which Shell are you using in Linux and in Unix?
It depends on the shell. |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Add a shebang to the top Code:
#!/bin/bash and it should work under (most recent) versions of Solaris. You haven't specified an interpreter, so it'll default to using /bin/sh - fine for Linux ( /bin/sh is usually a symlink to /bin/bash ) but not SunOS where /bin/sh is the Bourne shell or Korn Shell depending on version (Solaris 11 has a symlink to ksh93 ). |
|
#4
|
||||
|
||||
|
sun = /bin/ksh
linux = /bin/ksh |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Hi,
Did you try adding #!/bin/bash to the top of your script when running under Solaris, and trying again? Whilst your shell may be /bin/ksh , that's not what is necessarily interpreting your script unless you explicitly state your interpreter with a shebang. Cheers, ZB |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
This is not valid syntax in any shell: Code:
for count=0; count<arrlen; count++ ; do |
| Sponsored Links | |
|
|
#7
|
||||
|
||||
|
i try it. but not work. ---------- Post updated at 06:16 PM ---------- Previous update was at 06:11 PM ---------- Code:
SunOS Proton 5.8 Generic_Virtual sun4u sparc SUNW,SPARC-Enterprise Code:
#!/usr/bin/ksh error : syntax error at line 12: `arr=' unexpected Code:
#!/usr/bin/sh error : syntax error at line 12: `arr=' unexpected Code:
#!/usr/bin/bash error : syntax error near unexpected token `((' : line 20: `for ((count=0; count<arrlen; count++)) ; do' |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [?] Does Netflix work on Linux in Firefox? | KenJackson | What's on Your Mind? | 4 | 03-22-2012 08:58 PM |
| Help gettgin this script to work on linux | binary-ninja | Shell Programming and Scripting | 4 | 08-23-2011 11:24 AM |
| Script doesn't work, but commands inside work | cheongww | UNIX for Dummies Questions & Answers | 2 | 11-14-2006 09:52 PM |
| Work on Linux Using Bootable CD ?? | newbie07 | UNIX for Dummies Questions & Answers | 2 | 04-25-2006 12:48 AM |
| ISDN on Linux..will it work? | Phaelanx | UNIX for Dummies Questions & Answers | 4 | 03-01-2002 11:59 AM |
|
|