Google Groups Home
Help | Sign in
Message from discussion Sourcing file in the same shell using a command and csh
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Stephane CHAZELAS  
View profile
 More options May 9, 11:07 am
Newsgroups: comp.unix.shell
From: Stephane CHAZELAS <this.addr...@is.invalid>
Date: Fri, 9 May 2008 17:07:59 +0200 (CEST)
Local: Fri, May 9 2008 11:07 am
Subject: Re: Sourcing file in the same shell using a command and csh
2008-05-9, 07:25(-07), amiro...@googlemail.com:
[...]
> How can I solve the following scenario:

> /--- source-file ---
>| setenv MYPATH /my/path
> \-----------------------

> /--- executable-file ---
>| #!/bin/csh
>| source source-file
> \-----------------------------

> After running ./executable-file $MYPATH is not visible anymore since
> the source-command has been executed in a different shell. If I remove
> the shebang I get "./executable-file: line 1: setenv: command not
> found".

> How can I source a file in the running shell with the help of a
> command?

[...]

If you're shell is csh compatible, use

source executable-file

If not, maybe what you're after is something like:

eval "$(csh -c 'source source-file; sh -c export\ -p')"

(assuming "sh" is a POSIX sh; on Solaris, you need
PATH=$(getconf PATH):$PATH export PATH to pick the correct sh).

--
Stéphane


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google