Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sh being executed instead of csh

Status
Not open for further replies.

pankajpanjwani

Technical User
Mar 25, 2002
24
EU
Hi,
I am trying to set some environment variable in my paren shell which are available in a file.

file : test.csh
.....................
source someFilePath/someFile
setenv NEW2 NEW2

...................

test.csh has executable permission, and I am running it on csh.
When I try to execute this file, it gives me a message saying "source: not found" and "setenv: not found"
which means that it is trying to invoke a bourne shell for executing this script.
my attributes in /etc/passwd show that my default shell is /bin/csh.
What I want is that to simply execute the commands and set these variables in parent shell without invoking a new child shell (for which I can use #!/bin/csh)

If you have any clue whats happening here, please let me know, as this is also disturbing me in executing some c-shell functions through tcl, perl & cron scripts.

thanks in anticipation
Pankaj
 
you should be using a "." to source the environment
to the parent shell.

. ./some_environment_file Robert G. Jordan
Unix Sys Admin
Sleepy Hollow, Illinois U.S.A.
sh.gif


FREE Unix Scripts
 
Robert,
I did not get this, do you mean that i should start
test.csh as
./test.csh
In that case, I am doing so.

if you have any suggestion for setting environment variable in parent shell through a script(which is sourcing an environment setup file), please let me know

thanks
 
I mean

. ./test.csh

OR

. test.csh

depending on if you have the present working directory
in your path.

In either case, I believe the leading . tells
the the shell to source and variables set
in the test.csh script to the current shell.

I don't know if it is required, but I would make sure
that the id you are using to invoke this script is
using the same shell type (csh) as the script is
since you are trying to source the variables.

Robert

Robert G. Jordan
Unix Sys Admin
Sleepy Hollow, Illinois U.S.A.
sh.gif


FREE Unix Scripts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top