LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-04-2008, 01:09 PM   #1
Mart777
LQ Newbie
 
Registered: Aug 2006
Posts: 2

Rep: Reputation: 0
Program starting other application


Hi,

My question is about writing a short program hat would be able to do the following:
- start other executable
- detect when that other executable completed its work

This short program would start other executable multiple times, e.g.: one time then wait till it finishes, modify output files and prepare new input files for that other executable then start again, and so on.

What would be good to use to write it to work under linux. I thought c++, is there any better language for this? Working on the files in between would be a bit extensive, so I thought c++ would be good for it. Do you know any place they explain how to do it to work under linux (we have CentOS 5).

Thank you.
-Mart
 
Old 04-04-2008, 01:46 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
How about bash?
Code:
#! /bin/bash
while [ 1 ] ;
do
  echo starting
    ls -lash > dir.log
    sed -i s/^\\.// dir.log
    sleep 1
  echo ending
done;
It's what a shell is for.
--- rod.
 
Old 04-04-2008, 01:51 PM   #3
beadyallen
Member
 
Registered: Mar 2008
Location: UK
Distribution: Fedora, Gentoo
Posts: 209

Rep: Reputation: 36
Is there a reason you can't just use a shell script? Something like the following will work for simple cases:
Code:
#!/bin/sh

#This assumes you're program takes an inputfile called "input.dat", 
#and creates an ouput called "output.dat".
#Then you run progProcessResults to generate a new input file 
numruns=10
inputname="input.dat"
outputname="output.dat"

for ((i=1;i<=$numruns;i++))
do
  progmain $inputname $outputname
  progProcessResults $outputname $inputname
done
If you're sure you need to do it from within your own compiled program, have a look at 'man system'

edit: Beaten to it. Lol
 
Old 04-04-2008, 02:02 PM   #4
Mart777
LQ Newbie
 
Registered: Aug 2006
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you!
I learned some basic shell script, but I see I will have to learn it more.
-Mart
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Vodafone Application not starting CrownAmbassador Linux - Software 5 02-18-2008 06:59 AM
starting X application remotely spidy_123 Linux - Networking 2 10-19-2005 05:45 AM
rc.local not starting my application Greenman Linux - Newbie 11 08-17-2004 03:35 PM
Starting an application at boot ftwomey Linux - Newbie 3 04-25-2004 07:07 AM
Auto starting an application bbereg Linux - Newbie 7 11-21-2002 04:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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