Re: question about setenv



EdStevens schrieb:


#!/bin/sh
-set x
setenv ORACLE_SID mysid

When running the script, the setenv line returns "setenv: not found"

setenv is a C-Shell builtin, not a Bourne Shell builtin. See "man sh"
and "man csh".
The corresponding sh command is "export". If you use csh as your login
shell, be aware of the (very) different syntax (you told your script
to use #!/bin/sh !)

ORACLE_SID=mysid
export ORACLE_SID

Note that "export" and "setenv" do not really setenv or export from a
sub shell
(script). If you use csh, either put setenv commands to .login or
..cshrc
and use "alias" if you want to set environment variables interactively

Put in .login

alias ods "setenv ORACLE_SID=mysid"

The you can use the "command" ods to set the environment.

If you put environment variables in a C-Shell script, you must (!)
source it:

#!/bin/csh
# -- script ods.csh
setenv SID 1
setenv X 2
The you must source this:

source ods.csh

You can also define an alias

alias ods="source ods.csh"

By the way: do not use C-Shell for serious scripts (using it as a login
shell is ok)

http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

Hubble.

.



Relevant Pages

  • Re: setenv does not work
    ... SunOS 5.9. ... depends on which shell you are using. ... "setenv" applies to c-shell. ...
    (comp.unix.shell)
  • Re: detect shell script language
    ... In the 'old' days, when a user typed in a command, the interactive shell would immediately pass it off to 'exec' to execute. ... So, on return from exec with an error status, the shell would fork a copy of itself to try and run the script. ... As a result of the above, it was hard to tell whether the script was a Bourne shell or C shell, so the convention was introduced of using the Bourne shell no op command, as the first line in a Bourne shell script. ...
    (Debian-User)
  • Re: Call for input on comp.unix.shell FAQ
    ... >> questions and just tell people to FAQ it. ... The other level is how to write shell scripts. ... How can I remove whitespace characters within file names? ... Why one shouldn't use "echo" in a script? ...
    (comp.unix.shell)
  • SHELLdorado Newsletter 1/2003 - July 6th, 2003
    ... The "SHELLdorado Newsletter" covers UNIX shell script related ...
    (comp.unix.questions)
  • SHELLdorado Newsletter 1/2003 - July 6th, 2003
    ... The "SHELLdorado Newsletter" covers UNIX shell script related ...
    (comp.unix.shell)