LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 01-11-2006, 07:30 PM   #1
3saul
Member
 
Registered: Aug 2004
Location: Brisbane, Australia
Distribution: Ubuntu/Fedora
Posts: 86

Rep: Reputation: 15
Call external application


I'm wanting to call sed from and have its stdout given to a variable in my program. How do I call external applications?
 
Old 01-11-2006, 08:06 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
If the file files.txt contains

Quote:
cryptostore
QHStore
securedFile
And the following is run:

Code:
export NEWVAR=`sed -r -e '/^[^Q]/d' files.txt`
Then the result is:

Code:
echo $NEWVAR
QHStore
Basically, the `` notation runs a command for you. You can also use $(command) notation. There's more info in `man bash` under Command Substitution.
 
Old 01-11-2006, 08:37 PM   #3
3saul
Member
 
Registered: Aug 2004
Location: Brisbane, Australia
Distribution: Ubuntu/Fedora
Posts: 86

Original Poster
Rep: Reputation: 15
And how would I do that in C?
 
Old 01-11-2006, 08:52 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
ouch - no fair, I don't use the C shell. Try:

Code:
setenv NEWVAR `sed -r -e '/^[^Q]/d' files.txt`
 
Old 01-11-2006, 08:56 PM   #5
3saul
Member
 
Registered: Aug 2004
Location: Brisbane, Australia
Distribution: Ubuntu/Fedora
Posts: 86

Original Poster
Rep: Reputation: 15
No I meant in the C programming language!...but thanks for the reply!
 
Old 01-11-2006, 09:09 PM   #6
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Now you've really got me beaten - C?

Code:
./configure && make && make install
Now what?
 
  


Reply



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
Call external prog from withing chroot jail The_JinJ Linux - General 2 12-13-2005 04:38 PM
Getting an application icon to "call 'home'" southsibling Linux - Software 4 10-02-2005 08:37 AM
Opening an external application using Qprocess in QT designer nunation Programming 3 01-30-2005 02:39 AM
What do you call your remote control? I call mine... RHLinuxGUY General 19 10-18-2004 06:23 AM
Call Other Application by one Program kiennd Programming 4 08-02-2003 01:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration