Professional Web Applications Themes

run following shell error on solaris but OK on RedHat, why???? - Sun Solaris

Dear all, I run following shell on red hat without any error. ========================================== foo=1 while [ "$foo" -le 20 ] do echo "Here we go again" foo=$(($foo+1)) done exit 0 ========================================== But, when I run some shell on Solaris 9. I got following error message: foo: syntax error at line 6: `foo=$' unexpected What is the problem?? pls help me. thanks!...

  1. #1

    Default run following shell error on solaris but OK on RedHat, why????

    Dear all,

    I run following shell on red hat without any error.
    ==========================================
    foo=1

    while [ "$foo" -le 20 ]
    do
    echo "Here we go again"
    foo=$(($foo+1))
    done

    exit 0
    ==========================================

    But, when I run some shell on Solaris 9.
    I got following error message:

    foo: syntax error at line 6: `foo=$' unexpected

    What is the problem??
    pls help me.

    thanks!
    Rick Ng Chi Wah Guest

  2. #2

    Default Re: run following shell error on solaris but OK on RedHat, why????

    Rick Ng Chi Wah <ngchiwah9netscape.net> heeft geschreven,
    > Dear all,
    >
    > I run following shell on red hat without any error.
    > ==========================================
    > foo=1
    >
    > while [ "$foo" -le 20 ]
    > do
    > echo "Here we go again"
    > foo=$(($foo+1))
    > done
    >
    > exit 0
    > ==========================================
    >
    > But, when I run some shell on Solaris 9.
    > I got following error message:
    >
    > foo: syntax error at line 6: `foo=$' unexpected
    >
    > What is the problem??
    > pls help me.
    Nu clue, but my machine say this:
    bash-2.05$ uname -a
    SunOS sun30 5.9 Generic_112233-05 sun4u sparc SUNW,Ultra-30
    bash-2.05$ echo $SHELL
    /usr/bin/bash
    bash-2.05$ foo=1
    bash-2.05$ while test $foo -le 5; do echo "next"; foo=$(($foo+1)); done
    next
    next
    next
    next
    next
    bash-2.05$

    I replace the [...] by test because otherwise it says:
    bash: [1: command not found

    Wich shell are you using? On redhat bash is default, on Solaris
    you get whatever your sysadmin thinks is cool....
    kansloos@xs4all.nl Guest

  3. #3

    Default Re: run following shell error on solaris but OK on RedHat, why????

    On 22 Jul 2003, Rick Ng Chi Wah wrote:
    > Dear all,
    >
    > I run following shell on red hat without any error.
    > ==========================================
    > foo=1
    >
    > while [ "$foo" -le 20 ]
    > do
    > echo "Here we go again"
    > foo=$(($foo+1))
    > done
    >
    > exit 0
    > ==========================================
    >
    > But, when I run some shell on Solaris 9.
    > I got following error message:
    >
    > foo: syntax error at line 6: `foo=$' unexpected
    >
    > What is the problem??
    The problem is Linux's sh not being sh - it's bash. One
    the Solaris machine, try putting this as the first line
    of the script:

    #!/bin/ksh

    This is one of those examples that show that it is usually
    better to write code on a non-Linux machine, and port it
    to Linux, rather than the other way round.

    --
    Rich Teer, SCNA, SCSA

    President,
    Rite Online Inc.

    Voice: +1 (250) 979-1638
    URL: [url]http://www.rite-online.net[/url]

    Rich Teer Guest

  4. #4

    Default Re: run following shell error on solaris but OK on RedHat, why????

    I believe you need to specify the shell you're using or execute it by
    initiating a sub-shell first, i.e., ksh scriptname. I don't believe
    bourn shell can handle (()) calculation.

    Rich Teer <rich.teerrite-group.com> wrote in message news:<Pine.GSO.4.44.0307220855240.23779-100000zaphod.rite-group.com>...
    > On 22 Jul 2003, Rick Ng Chi Wah wrote:
    >
    > > Dear all,
    > >
    > > I run following shell on red hat without any error.
    > > ==========================================
    > > foo=1
    > >
    > > while [ "$foo" -le 20 ]
    > > do
    > > echo "Here we go again"
    > > foo=$(($foo+1))
    > > done
    > >
    > > exit 0
    > > ==========================================
    > >
    > > But, when I run some shell on Solaris 9.
    > > I got following error message:
    > >
    > > foo: syntax error at line 6: `foo=$' unexpected
    > >
    > > What is the problem??
    >
    > The problem is Linux's sh not being sh - it's bash. One
    > the Solaris machine, try putting this as the first line
    > of the script:
    >
    > #!/bin/ksh
    >
    > This is one of those examples that show that it is usually
    > better to write code on a non-Linux machine, and port it
    > to Linux, rather than the other way round.
    Sonny Boy Guest

  5. #5

    Default Re: run following shell error on solaris but OK on RedHat, why????

    In article <google.com>,
    Rick Ng Chi Wah <net> wrote: 

    The shell code can be rewritten as follows to be more readable:

    ==========================================
    #!/usr/dt/bin/dtksh

    (( foo = 1 ))
    while (( foo <= 20 )); do
    echo "Here we go again"
    (( foo++ ))
    done

    exit 0
    ==========================================

    If your Linux does not have /usr/dt/bin/dtksh, you can download
    the RPM and install it:

    http://www.unixlabplus.com/linux-rpm/
    --
    Michael Wang * http://www.unixlabplus.com/ * com
    Michael Guest

Similar Threads

  1. [PHP] FDF support in RedHat (make error)
    By Jay Blanchard in forum PHP Development
    Replies: 3
    Last Post: August 8th, 10:58 PM
  2. Evolution shell error
    By Keith O'Connell in forum Debian
    Replies: 1
    Last Post: August 4th, 01:20 AM
  3. error message for Shell class
    By s moon in forum Ruby
    Replies: 2
    Last Post: August 1st, 02:00 PM
  4. Replies: 0
    Last Post: July 7th, 04:58 PM
  5. LSA Shell export version error
    By Kelly in forum Windows XP/2000/ME
    Replies: 1
    Last Post: July 7th, 12:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139