[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a question on C++



On Tue, 10 Jul 2001, b g wrote:

> Hi list!
> Can anyone help me with a problem i have?

Yes. But please refrain from cross-posting.

> i've written a c++ program (using kdevelop under radhat 7.1) which takes 12
> parameters. i need to run it several hundred times, changing each time
> another parameter. in order to do this another program was writen with a
> for loop in it.

why not write a simple bash/perl/whatever script to handle this? Those
languages handle IO and such much better than C/C++:

a bash sample:

#!/bin/bash

# create empty run.log and error.log
echo -n >run.log
echo -n >error.log

for PARAM1 in val1 val2 val3; do
  for PARAM2 in val4 val5 val6; do
    ./myprog $PARAM1 $PARAM2 2>1 >>run.log    
    # or maybe you would rather use:
    #./myprog $PARAM1 $PARAM2 >>run.log 2>>error.log
  done
done

> the loop contains system() comand, that boots the big program. everything
> goes ok untill i logout. when i do logout, the programs are killed.
> how can i prevent this?

On c++ you need to handle the hangup signal (with signal()) and make sure
that your program does not require input from the terminal or creates
output to the terminal.

Alternatively, you can run your test program (however you write it) with
screen.

(There is also a more premitive and less convinient 'nohup' program)

-- 
Tzafrir Cohen
mailto:tzafrir@technion.ac.il
http://www.technion.ac.il/~tzafrir




=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il