LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 04-01-2002, 10:30 AM   #1
llama_meme
Member
 
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

#!/bin/sh
variable=blah

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

thanks,
alex
 
Old 04-01-2002, 08:37 PM   #2
kwigibo
Member
 
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.

kwigibo
 
Old 04-01-2002, 09:10 PM   #3
crabboy
Moderator
 
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.
 
  


Reply


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 08:08 AM
Executing a shell script command!! vishamr2000 Programming 4 08-15-2005 12:33 AM
verify if the same shell script is executing in background hicham007 Programming 2 08-07-2005 05:40 AM
Auto-Executing Shell Script on boot benrose111488 Linux - Software 5 12-18-2004 12:52 AM
executing shell script on apache nooodles Linux - General 1 06-29-2004 01:51 AM


All times are GMT -5. The time now is 02:42 AM.

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