Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jun 2001 03:52:47 -0400 (EDT)
From:      "Albert D. Cahalan" <acahalan@cs.uml.edu>
To:        jim@freeze.org
Cc:        questions@freebsd.org
Subject:   Re: How to have a script set an environment variable
Message-ID:  <200106290752.f5T7ql2453217@saturn.cs.uml.edu>

next in thread | raw e-mail | index | archive | help

Jim Freeze writes:

> I don't know if this can be done, but I am would like
> to write a script that would set an environment variable
> for a particular terminal window.
>
> I am running tcsh. If I write a script such as:
> #! /bin/sh
> set TEST "test"
> export TEST
>
> TEST is set for the script, but not for the parent
> terminal. Is there a switch I can send to /bin/sh
> to use the parent's environment?

If you want to do this the fun way...

1. Get the PID of the shell in that "particular terminal window".
   (use "ps" and your choice of awk, perl, sed, etc.)
   Plain $$ will do if "particular terminal window" is the same
   place you run the script.

2. Run the debugger, feeding it commands that...

3. attach to the shell by the PID above

4. change the environment, including any app-specific cache

5. quit


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200106290752.f5T7ql2453217>