I'm working in linux. I have two programs that run for infinite time ( that is , wont stop unless i kill the process ).i want to run program 1 first and then run program 2 after 20 seconds ( both will have to run simultaneously as one reads a file written by the other ).Currently , i am running the 2 programs by manually keeping track of time.. Is there a way to automate this ? i.e. is there any command or can any program be written to do this..
the 2 programs are : first_auto.c and after 20 seconds , prime_auto.chow do i compile and run.. can you please explain..
trinity
2010-02-16 03:12:17
@trinity: That's a different question. Please ask a new question.
Greg D
2010-02-16 03:12:51
If you don't know how to compile your programs, that's something you should research first.
Tyler McHenry
2010-02-16 03:13:36
Huh! trinity - the trinity that hacked the IRS database....quote from the Matrix....
tommieb75
2010-02-16 03:21:04
@Greg and @Tyler : till then i thought i had to use ./a.out for both programs and hence the doubt.. Now i found out i could save the out files using the -o option.@Anon : Thanks a lot
trinity
2010-02-16 03:22:40
@trinity: You also have the option to rename them via `mv`.
Greg D
2010-02-16 06:45:46
A:
If one program reads from the file output by the other you should consider using a pipe to pass output from one to the input of the other:
$> program1 | program2
I'm assuming that you have control over these two programs and can get them to write to stdout
and read from stdin
.
Tom Duckering
2010-02-16 03:23:04
Actually , i maintain a circular buffer of files - f1 , f2 , f3.. and the first program writes into these files , switching between them every 20 seconds. And the reader program also reads from these. I have written the code to do this and it works fine..
trinity
2010-02-16 03:29:52