It is currently Thu, 20 Jan 2022 03:55:49 GMT



 
Author Message
 running bourne shell script from cshell
One of my Unix account has cshell as the default shell. I want to run some
of my bourne shell scripts under cshell. When I run it, I get "not an
identifier error".

For exmaple, my script test.sh

------------------------------------------
#!/bin/sh
export TEST=joe
echo $TEST
-------------------------------------------

I changed the permission by; chmod +x test.sh
and typed:  test.sh at the prompt.
I got the error command not found.

SO, I did sh test.sh  and I got the folllowing error:

test.sh TEST=joe is not an identifier.

The funny thing is if I change it to a ksh script by #!/bin/ksh, the script
works fine. I am wondering why ksh works under csh while bash does not work.



 Tue, 23 Nov 2004 05:48:57 GMT   
 running bourne shell script from cshell

    If you told it to use bash, it would work, but you told it to use
    /bin/sh. Change the shebang to #!/bin/bash.

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2002, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License



 Tue, 23 Nov 2004 05:53:09 GMT   
 running bourne shell script from cshell
In article <slrnafvmn1.ec0.c.f.a.john...@xword.rogers.com>,
Chris F.A. Johnson <c.f.a.john...@rogers.com> wrote:

That's because your current directory isn't in your $PATH.  Type: ./test.sh

Or change the script to valid Bourne shell syntax:

TEST=joe
export TEST
echo $TEST

Being able to combine the assignment and export into a single command is a
feature of ksh and bash, but not Bourne shell.

--
Barry Margolin, bar...@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



 Tue, 23 Nov 2004 07:21:37 GMT   
 running bourne shell script from cshell

Try
        ./test.sh

You must have an older sh.

Change

        export TEST=joe

to
        TEST=joe
        export TEST

--
Sending unsolicited commercial e-mail to this account incurs a fee of
$500 per message, and acknowledges the legality of this contract.



 Tue, 23 Nov 2004 08:36:09 GMT   
 running bourne shell script from cshell

Interestingly enough (and while you mention it) the following
construct has always been legal for all versions of sh and ksh
(although not bash.)

TEST=joe export TEST

=Brian



 Tue, 23 Nov 2004 10:21:20 GMT   
 running bourne shell script from cshell
Thanks everybody. I learned so much from this exercise. My script is working
fine now.

news:dNQL8.146839$%o.14001846@bin3.nnrp.aus1.giganews.com...



 Tue, 23 Nov 2004 20:20:32 GMT   
 running bourne shell script from cshell
in comp.unix.shell i read:

not bash?

| bash-1$ echo $TEST
|
| bash-1$ TEST=joe export TEST
| bash-1$ echo $TEST
| joe
| bash-1$ echo $BASH_VERSION
| 1.14.7(1)

| bash-2$ echo $TEST
|
| bash-2$ TEST=joe export TEST
| bash-2$ echo $TEST
| joe
| bash-2$ echo $BASH_VERSION
| 2.03.8(1)-release

--
bringing you boring signatures for 17 years



 Thu, 25 Nov 2004 11:29:58 GMT   
 running bourne shell script from cshell
those who know me have no need of my name wrote:

[maybe "he who does not want to share his name" could
consider to at least provide his real name (if not the real address),
because referring to such pseudo-names sounds a little
stupid sometimes...]

  > in comp.unix.shell i read:
  >>the following construct has always been legal for all versions of sh and
  >>ksh (although not bash.)
  >>
  >>TEST=joe export TEST
  >
  > not bash?
  >
  > | bash-1$ echo $TEST
  > |
  > | bash-1$ TEST=joe export TEST
  > | bash-1$ echo $TEST
  > | joe
  > | bash-1$ echo $BASH_VERSION
  > | 1.14.7(1)

This feature is used to set environment variables only for the
execution time of a script. Very old Bourne Shells used to
interpret variables specified *behind* the command name
as temporary assignments, e.g.

     ls $TEST TEST=$HOME                # does not work any longer

I wonder if these old shell support the new syntax, too.

Heiner
--
  ___ _
/ __| |_ _____ _____ _ _     Heiner STEVEN <heiner.ste...@nexgo.de>
\__ \  _/ -_) V / -_) ' \    Shell Script Programmers: visit
|___/\__\___|\_/\___|_||_|   http://www.shelldorado.com/



 Thu, 25 Nov 2004 19:03:23 GMT   
 running bourne shell script from cshell

- First, this example is very confusing, because it is also using
  "parameter expansion", which might occur _before_ the assignment.

- AFAIK, no Bourne shell variant ever has supported the above.
  Particularly, neither Version7 nor 4.3BSD accept it.

- But perhaps you confused this with "order of assignments"?

    $ foo=`echo $bar`  bar=text;   echo $foo

  It is "right to left" for all Bourne shells, except on UnixWare
  (or SVR4.2 in general?).  In all "modern" shells and particularly
  in POSIX.2 it has changed to "left to right" (i.e. prints nothing).

  $ a=b export a

has surely been working in all Bourne shells from the very beginning,
as also Brian has pointed out already (again: v7 and 43BSD know it).
Or do you know a particular version, in which this (allegedly) would
not work?

Sven



 Sat, 27 Nov 2004 02:04:34 GMT   
 running bourne shell script from cshell
  >> Heiner Steven <heiner.ste...@nexgo.de> wrote:
[...]
  >>Very old Bourne Shells used to interpret variables specified
  >>*behind* the command name as temporary assignments, e.g.
  >>
  >>    ls $TEST TEST=$HOME                # does not work any longer
  >
  > - First, this example is very confusing, because it is also using
  >   "parameter expansion", which might occur _before_ the assignment.

Agreed.

  > - AFAIK, no Bourne shell variant ever has supported the above.
  >   Particularly, neither Version7 nor 4.3BSD accept it.

Well, even the newest KornShell (ksh93) supports the above,
but (fortunately) it's no longer the default. Excerpt from
the ksh93 (1993-12-28 m) manual page:

        If  the obsolete -k option is set, all variable assignment
        arguments are placed in  the  environment,  even  if  they
        occur  after the command name.  The following first prints
        a=b c and then c:

               echo a=b c
               set -k
               echo a=b c
        This feature is intended for use with scripts written  for
        early  versions of the shell and its use in new scripts is
        strongly discouraged.  It is likely to disappear  someday.

  > - But perhaps you confused this with "order of assignments"?

no.

  >   $ a=b export a
  >
  > has surely been working in all Bourne shells from the very beginning,
  > as also Brian has pointed out already (again: v7 and 43BSD know it).
  > Or do you know a particular version, in which this (allegedly) would
  > not work?

I don't know of a version where it does not work, but I have had
no chance yet to test this with a *really* old version of "sh".

Heiner
--
  ___ _
/ __| |_ _____ _____ _ _     Heiner STEVEN <heiner.ste...@nexgo.de>
\__ \  _/ -_) V / -_) ' \    Shell Script Programmers: visit
|___/\__\___|\_/\___|_||_|   http://www.shelldorado.com/



 Sat, 27 Nov 2004 02:35:21 GMT   
 running bourne shell script from cshell

I didn't mean Bourne "compatible" shells, but the very members
of the also big family of Bourne shells themselves.



 Sat, 27 Nov 2004 02:55:54 GMT   
 running bourne shell script from cshell
  > Heiner Steven wrote:
  >
  >>Sven Mascheck wrote:
  >
  >>>- AFAIK, no Bourne shell variant ever has supported the above.
  >
  >>Well, even the newest KornShell (ksh93) supports the above,
  >
  > I didn't mean Bourne "compatible" shells, but the very members
  > of the also big family of Bourne shells themselves.

Does /bin/sh from Solaris 9 qualify as a family member?

     $ uname -a
     SunOS nuernberg 5.9 Beta_Refresh sun4u sparc SUNW,Ultra-5_10

Quote from the sh(1) manual page:

     [...]
      If the -k flag is set, all keyword arguments are  placed  in
      the  environment, even if they occur after the command name.
      The following example first prints a=b c and c:

      echo a=b  c
      a=b  c
      set  -k
      echo a=b  c
      c

Heiner
--
  ___ _
/ __| |_ _____ _____ _ _     Heiner STEVEN <heiner.ste...@nexgo.de>
\__ \  _/ -_) V / -_) ' \    Shell Script Programmers: visit
|___/\__\___|\_/\___|_||_|   http://www.shelldorado.com/



 Sat, 27 Nov 2004 05:07:51 GMT   
 running bourne shell script from cshell

Oh, certainly.  Actually this flag has been (omni-)present since
Version 7.  However, it has never been the *default* - with which
i had gotten stuck (sorry), after you mentioned "Very old Bourne
shells used to [...] does not work any longer".



 Sat, 27 Nov 2004 07:56:10 GMT   
 
   [ 13 post ] 

Similar Threads

1. BUG IN BOURNE SHELL AND/OR CSHELL ??

2. Bourne shell script to determine users shell

3. Bourne shell script affecting current shell with arguments

4. Trying to run nohup from Korn shell but getting Bourne shell errors

5. A Solaris 8 (Bourne Shell) Scripting question, regarding a log rotation script

6. help in learning how to do Bourne shell scripts then converting them to csh scripts

7. Light Speed Bourne Shell! (was: Bourne shell tricks)

8. running Cshell scripts on NT 4.0

9. make that uses Cshell instead of Bourne


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software