On 07/18/2016 08:30 PM, Kurtis Rader wrote:
On Mon, Jul 18, 2016 at 4:37 PM, Patrick <patr...@spellingbeewinnars.org <mailto:patr...@spellingbeewinnars.org>> wrote:

    What I would like to do, is to write a fish script that ran a bunch of
    commands returning the values in environment variables. I would then
    like to access those variables from C( actually COBOL).

    I know this can be done with bash but is there a way to do it with
    fish ?

    The standard libraries will assume bash not fish.


It is not clear what you're trying to do. In the UNIX process model environment variables are passed from the parent process to its child processes. A child process cannot directly modify the environment vars of its parent process. The only way to do so is via a cooperative strategy. For example, the child process could write each env var to stdout in the form "name=value\n" (you'll need to figure out how to encode newlines in the value to make this bullet proof). The parent process would then create a pipe and attach the stdout of the child process to one end of the pipe. The parent process then reads the "name=value" lines from the other end of the pipe and does whatever it wants with those env vars -- including self-modifying its own set of env vars. In C you would do that with the `putenv()` or `setenv()` functions.

Note that your problem statement, as written, is not unique to the fish shell. The answer would be the same if you used bash or zsh.

--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank


Hi Kurtis and all

It took a while for my post to end up broadcast to the list. I figured things out in the meantime.

I opened up fish
I created a variable and exported it
I launched my COBOL program from within fish
I was able to read the environment variable fine

Sorry for the noise everyone!

-Patrick


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to