nash@sdsu.UUCP (Ron Nash) (02/27/88)
How can I pass varibles (other than environment varibles) to /bin/csh? I have a C program that uses execve to pass the environment varibles, but it does not pass local (the ones shown via the csh 'set' command) to the child shell. Has anyone done this? Is it possible to set local variables from within a C program so that a child will inherit them? Any ideals would be greatly appreciated! Ron Nash San Diego State University Phone: (619)265-4363 uucp: ..ucsd!sdsu!nash
ford@kenobi.UUCP (Mike Ditto) (02/29/88)
Posting-Front-End: GNU Emacs 18.41.10 of Fri Oct 2 1987 on kenobi (usg-unix-v) In article <2937@sdsu.UUCP> nash@sdsu.UUCP (Ron Nash) writes: > How can I pass varibles (other than environment varibles) to /bin/csh? > I have a C program that uses execve to pass the environment varibles, but > it does not pass local (the ones shown via the csh 'set' command) to the > child shell. Has anyone done this? Is it possible to set local variables > from within a C program so that a child will inherit them? That last sentence summarizes the situation. A "local" shell variable is one which was created in the current process and will not be passed to any other processes. Local variables are meant to be used as their name suggests, as local variables. Variables which are inherited by exec'ed processes are called "environment variables", and you obviously know how to use those. Apparently, your goal is to run a csh that will define some shell variables before beginning to execute commands. There is no straightforward way to do this, but you can put "set" statements in the .cshrc file, or at the beginning of the script to be executed. If that is not acceptable, or if you are creating an interactive csh, try something like /* autologout=42 is just an example, replace with your assignments */ execlp("/bin/csh", "csh", "-ci", "set autologout=42;source /dev/tty"); although I don't know if prompting will work properly. -=] Ford [=- "Well, he didn't know what to do, so (In Real Life: Mike Ditto) he decided to look at the government, ford%kenobi@crash.CTS.COM to see what they did, and scale it ...!sdcsvax!crash!kenobi!ford down and run his life that way." -- Laurie Anderson