Visit the LQ Articles and Editorials section
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-01-2002, 11:30 AM   #1
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
executing a shell script from C

bit of an obscure question, but here goes...
is there any way of executing a shell script inside a C program, and then accessing the enviroment of that shell script using getenv()?

e.g., if i had the script


could i execute it within my program and then find the value assigned to variable?

Old 04-01-2002, 09:37 PM   #2
Registered: Apr 2002
Location: Australia
Distribution: Mandrake 8.2
Posts: 53

Rep: Reputation: 15
i know you can execute programs with the call

system(char *)

so considering shell scripts have xcutable permission you could go along that line. I really don't know if this is what your after or not though.

Old 04-01-2002, 10:10 PM   #3
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
I think if you export the vars in the shell that you create it may work, but I've never done it that way. Unless you are really stuck on using the env vars, I'd suggest that you use popen and get the output of the script via a pipe.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
executing konsole from shell script Meriadoc Linux - Newbie 10 07-10-2009 09:08 AM
Executing a shell script command!! vishamr2000 Programming 4 08-15-2005 01:33 AM
verify if the same shell script is executing in background hicham007 Programming 2 08-07-2005 06:40 AM
Auto-Executing Shell Script on boot benrose111488 Linux - Software 5 12-18-2004 01:52 AM
executing shell script on apache nooodles Linux - General 1 06-29-2004 02:51 AM

All times are GMT -5. The time now is 09:43 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration