It is currently Tue, 30 Nov 2021 16:52:24 GMT



 
Author Message
 environment vars in sh script
I'm writing an sh script and a C program, and I need them to both have
access to a variable created in teh script.

What I want to do is create a global environment variable in the script
which I can read in C with getenv()

I've tried doing:

   set varName=value    and
   set varName value

which don't seem to work

Any ideas? I'm sure it's a common problem...

Kevin



 Sun, 12 Aug 2001 03:00:00 GMT   
 environment vars in sh script
In article <36D4224B.5C9A6...@cs.strath.ac.uk>,
Kevin Burges CES1995  <kbur...@cs.strath.ac.uk> wrote:

varName=value
export varName

The first line assigns a shell variable (Bourne shell's "set" command is
for setting options and assigning to positional parameters -- you seem to
be confusing it with C-shell's "set" command) and the export command turns
a shell variable into an environment variable.

--
Barry Margolin, bar...@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



 Sun, 12 Aug 2001 03:00:00 GMT   
 environment vars in sh script

thanks everyone for the help. I was indeed confusing the two, because
i'm running csh but the scripts are under sh.  Also I was forgetting the
fact that environment vars I create in my scripts are only within that
shell's environment, not that of the calling shell.

Everything's OK now...

Kevin



 Mon, 13 Aug 2001 03:00:00 GMT   
 
   [ 3 post ] 

Similar Threads

1. sh vars in awk scripts??

2. Strange script problems - can't set environment vars

3. sh: read vars from file

4. Length of sh or ksh environmental vars

5. Maintaining white space in vars (/bin/sh)

6. using /bin/sh vars in awk

7. SUMMARY: using sh vars in awk calls.

8. environment vars....

9. Solaris 8 CDE and environment vars

10. * Passing environment vars to the same shell! *


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software