How to pass envvars from calling shell to called program?

How to pass envvars from calling shell to called program?

Post by Andreas Schere » Wed, 10 Jul 2002 03:48:02



Hi all!

I want (have to) pass the envvar $LINES & $COLUMNS to a called
program. The vars are only available in interactive shells, so
getenv()
does not work.

One way to do so, is to call the app with appname $LINES $COLUMNS
but this is not the way I like to do it.

Do anybody know a way to determine the number of lines and
columns
inside a c-program?

Please help me. Give me some hint, please.

mfg, Andreas.

 
 
 

How to pass envvars from calling shell to called program?

Post by Kasper Dupon » Wed, 10 Jul 2002 04:08:26



> Hi all!

> I want (have to) pass the envvar $LINES & $COLUMNS to a called
> program. The vars are only available in interactive shells, so
> getenv()
> does not work.

> One way to do so, is to call the app with appname $LINES $COLUMNS
> but this is not the way I like to do it.

> Do anybody know a way to determine the number of lines and
> columns
> inside a c-program?

> Please help me. Give me some hint, please.

> mfg, Andreas.

Your question was already answered once. Read the answer and
stop asking.

--
Kasper Dupont -- der bruger for meget tid p? usenet.


 
 
 

How to pass envvars from calling shell to called program?

Post by Lew Pitch » Wed, 10 Jul 2002 04:14:48


On Mon, 8 Jul 2002 20:48:02 +0200, "Andreas Scherer"


>Hi all!

>I want (have to) pass the envvar $LINES & $COLUMNS to a called
>program. The vars are only available in interactive shells, so
>getenv()
>does not work.

A couple of choices...

a) Run your program in a shell
   For instance...

   #!/bin/bash
   export LINES=32
   export COLUMNS=99
   /path/to/myprogram

b) Write a wrapper program that exec[l|v]e's your program, and set the
   environment vars as part of the exec[l|v]e call

With either of these, getenv() will work.

Quote:>One way to do so, is to call the app with appname $LINES $COLUMNS
>but this is not the way I like to do it.

>Do anybody know a way to determine the number of lines and
>columns
>inside a c-program?

Use argc/argv, of course (or the getargs() package if you don't like
handparsing argc/argv).

  /path/to/myprogram -lines 32 -columns 99

of course, you still have to populate the values, so you might be back to
envvars. If so, then your best bet is the wrapper shell script or wrapper
exec[l|v]e program.

Lew Pitcher, Information Technology Consultant, Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employer's.)

 
 
 

1. How to get calling program name in called program

Hi,

When one program executes another, the child can get the parent pid and,
using ps, grep and awk get the name of the calling process (or is there a
simpler way in C?).

Is there a way for the child to get the name of a script if it was called
from one?  Since the script is not a process, the abovementioned method
won't work, eg:

Assume program foo and script foo.script.  I want to be able to get
"foo.scipt" in foo if foo was called from foo.script.  Is this as
impossible as it seems?

Thank you
Marcel Groenewald

ISCOR Newcastle
South Africa



2. what is a door in solaris?

3. program calls rcmd() twice, _second_ call works for root but not normal users

4. RPM -a QUESTION on redhat 5.2

5. Fvwm calling xterm calling another program

6. Sun Unix & Layer-3/IP Switching

7. How to tell if shell program was called by another program.

8. Memory Use high in DATA SEGMENT..HELP!

9. Is there a system call that will be called for sure when a program exit?

10. passing string variable from script to a calling c++ program

11. Calling a Korn Shell script from a C-program

12. Question About Calling Shell in C Program

13. Calling shell commands from a C program?