Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

My script work on Linux but not work in sunos.

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-30-2013
ooilinlove's Unix or Linux Image
ooilinlove ooilinlove is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 30 July 2015, 5:05 AM EDT
Posts: 75
Thanks: 12
Thanked 0 Times in 0 Posts
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
done

run 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  
Old Unix and Linux 01-30-2013
panyam panyam is offline Forum Advisor  
Registered User
 
Join Date: Sep 2008
Last Activity: 8 December 2014, 6:40 AM EST
Posts: 1,159
Thanks: 20
Thanked 105 Times in 100 Posts
Which Shell are you using in Linux and in Unix?

It depends on the shell.
Sponsored Links
    #3  
Old Unix and Linux 01-30-2013
zazzybob's Unix or Linux Image
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
 
Join Date: Dec 2003
Last Activity: 13 May 2013, 9:02 AM EDT
Location: Melbourne, Australia
Posts: 2,185
Thanks: 3
Thanked 25 Times in 23 Posts
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  
Old Unix and Linux 01-30-2013
ooilinlove's Unix or Linux Image
ooilinlove ooilinlove is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 30 July 2015, 5:05 AM EDT
Posts: 75
Thanks: 12
Thanked 0 Times in 0 Posts
sun = /bin/ksh
linux = /bin/ksh
Sponsored Links
    #5  
Old Unix and Linux 01-30-2013
zazzybob's Unix or Linux Image
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
 
Join Date: Dec 2003
Last Activity: 13 May 2013, 9:02 AM EDT
Location: Melbourne, Australia
Posts: 2,185
Thanks: 3
Thanked 25 Times in 23 Posts
Quote:
Originally Posted by ooilinlove View Post
sun = /bin/ksh
linux = /bin/ksh
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  
Old Unix and Linux 01-30-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 31 August 2015, 3:04 PM EDT
Location: Amsterdam
Posts: 10,431
Thanks: 358
Thanked 2,769 Times in 2,475 Posts
This is not valid syntax in any shell:

Code:
for count=0; count<arrlen; count++ ; do

Sponsored Links
    #7  
Old Unix and Linux 01-30-2013
ooilinlove's Unix or Linux Image
ooilinlove ooilinlove is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 30 July 2015, 5:05 AM EDT
Posts: 75
Thanks: 12
Thanked 0 Times in 0 Posts
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
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 is 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



All times are GMT -4. The time now is 03:46 PM.