LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-09-2002, 02:59 AM   #1
lea
Member
 
Registered: Jul 2002
Posts: 31

Rep: Reputation: 15
call shell or other program out of my_program


Hi all!

* I would like to call a (linux)shell out of a my_program - but how?
* How do I leave this shell and return to my_program (I suppose with <exit>)?
* Is it possible to call another program (ie editor) directly out of my_program?

More specific:
I want to call an determined) editor to edit a (determined) textfile, like <call /usr/bin/vi ~/001.txt> (where vi and 001.txt are determined in my_program) and when I exit the edit process I return to my_program.
The program I want to write is a simple console based (ncurses) mind-mapping-tool.

TIA
Lea
 
Old 10-09-2002, 04:13 AM   #2
aizkorri
Member
 
Registered: Feb 2002
Location: Basque Country
Distribution: Fedora 14, Ubuntu 14.04
Posts: 434
Blog Entries: 1

Rep: Reputation: 55
you can use

system("whatever_editor_you_want yourfile")
 
Old 10-09-2002, 05:20 AM   #3
lea
Member
 
Registered: Jul 2002
Posts: 31

Original Poster
Rep: Reputation: 15
Thanks for your very fast help (and your patience with a newbie)

Lea
 
Old 10-09-2002, 10:51 AM   #4
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
System appears to be the right call for what you want to do now. But you might also want to do a man exec and check out all the functions they give you there, some of them are useful for other purposes.

Like if I wanted to spawn a process but not wait for it to finish before proceeding I would do something like this:

if(fork() == 0)
{
exec(blahblahblah);
}

Oh ya... do a man fork too, it is a pretty powerful function as well, but be careful when using it.
 
  


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
Shell Script call API treotan Programming 1 08-22-2005 10:59 PM
call a c program in a shell script jagman Programming 4 04-05-2005 04:58 PM
Urgent: Call a C program through Linux shell script nuwandee Programming 14 04-10-2004 07:31 PM
How to call the arp linux shell command from within a perl program Bassam Programming 1 03-11-2004 02:00 AM
how to put a shell call in a C/C++ program? Hano Programming 8 05-19-2002 02:26 PM

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

All times are GMT -5. The time now is 10:53 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