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
 
Hi,

put

#!/bin/csh

as the very first line of the script. No spaces
 
tdatgod,
I understand in that case it'll work, but with that it'll start a new child process, and changes to parent shell wont occur.
I have stated in my problem that
".....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)....."

Pankaj
 

if you are at a csh prompt or inside a CSH script you simply say


source file

and the contents of file are applied to the current shell.

but you already know that since, That is what you original post says so what's the problem with source?

CRON doesn't use your default shell. It always uses SH. So does PERL when you use `command` or system(command) Probably TCL as well.


the only way to get CRON or perl to execute your script in CSH is to put the

#!/bin/csh

at the top of the script. then inside the script say

source otherscript

and it will apply that script to current shell.
 
tdat,
thanks for all those information, i used to think that there is something related between the default shell and the shell invoked by perl or cron. Probably, I need to modify these scripts accordingly.
thanks for responding
Pankaj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top