Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running several command/subprograms simultaneously

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi there..

I need some help in doing the following..

Basically, i have four subprograms A, B, C and D that i need to call like the following:


A1---------->A2-------->A3-------->A4------ etc etc
| | | |
B1 B2 B3 B4
| | | |
C1 C2 C3 C4
| | | |
D1 D2 D3 D4


the way i need it to run is such like:

run A1
if (A1 finishes){run A2, (run B1 and then C1 and then D1)};
if (A2 finishes){run A3, (run B2 and then C2 and then D2)};
if (A3 finishes){run A4, (run B3 and then C3 and then D3)};

and etc etc etc...

the sub procedures are all in perl that calls some system commands, pass variables and do some processing but do not interact with each other.. but it has to run in the above order..

Is there a way to do this? anybody

Thanks in advance

Redza
 
Do you mean something like the following??...
Code:
#!/usr/bin/perl
# call A1, then A2, then A3....
&A1;
&A2;
&A3;

#sub-routines A1 - A3
sub A1
{
  &B1;  &C1;  &D1;
}

sub A2
{
  &B2;  &C2;  &D2;
}

sub A3
{
   ...etc...

Cheers
Loon
 
Hi there..

no, not really.. what i need is such that

1) We start off with running A1
2) Once A1 finishes, A2 and B1 starts
3) Once A2 finishes, A3 and B2 starts
4) Once A3 finishes, A4 and B3 starts

Also, while this is happening, once the B's finish, it continues on with the C's and after that, the D's

I think i've figured out how to do this if they are commands

we run something like A1; (B1; C1; D1)& A2; (B2; C2; D2)& A3
..... and it goes on and on... i think it *should* work..

However, i need to know.. what if A, B C and D are subprocedures, not commands?
 
Hi there..

no, not really.. what i need is such that

1) We start off with running A1
2) Once A1 finishes, A2 and B1 starts
3) Once A2 finishes, A3 and B2 starts
4) Once A3 finishes, A4 and B3 starts

Also, while this is happening, once the B's finish, it continues on with the C's and after that, the D's

I think i've figured out how to do this if they are commands

we run something like A1; (B1; C1; D1)& A2; (B2; C2; D2)& A3
..... and it goes on and on... i think it *should* work..

However, i need to know.. what if A, B C and D are subprocedures, not commands?


Thanks
RAshyid
 
Redza

OK, I am not sure what you mean when you say subprocedures, if you mean sub-routines i.e. you declare them thus:
Code:
sub A1
{
  #stuff goes in here
}
Or, if you are thinking of them as distinct processes/programs/threads what have you. I.e. is A1 in a different file to A2?

It sounds as though A1-A4 are perl scripts, whereas B1-D1 are sub-routimes, B2-D2 are sub-routines etc...

So:
Code:
#!perl
# perl proggy for A1

#first we do any work required of A1
# ...
# then:

&B1;
&C1;
&D1;
system("A2.pl");
exit;

Your A2, A3, ... An perl scripts would look similar but calling the next B, C and D subs along..

Is this closer?!?!
Loon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top