Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > how to call exec multi-times...

Reply
Thread Tools

how to call exec multi-times...

 
 
Jianli Shen
Guest
Posts: n/a
 
      09-21-2005
Hi,

I write the following script,
hope it call "atouRcv -b ***** & " in each iteration.
however, it only call once when $port=6811

is that because: exec will not call the END block, nor will it call any
DESTROY method in the object ???

how can I make this loop work ??

Thanks


#!/usr/bin/perl

my $port=6811;
foreach my $r ( 0, 50, 200 ){
foreach my $l (0, 0.01, 0.05){
for (my $i=0; $i<=9; $i++) { #each run 10times
exec "atouRcv -b 2000000 -r ". $r . " -l ". $l . " -p " . $port . " &
";
$port += 1;
}
}
}


 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      09-21-2005
"Jianli Shen" <> wrote in
news:dgqnvp$mgj$:

> is that because: exec will not call the END block, nor will it call
> any DESTROY method in the object ???


perldoc -f exec

exec LIST
exec PROGRAM LIST
The "exec" function executes a system command *and never
returns* ...

Read the documentation for more information.

Have you seen the posting guidelines for this group?

Sinan
--
A. Sinan Unur <>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html
 
Reply With Quote
 
 
 
 
Jianli Shen
Guest
Posts: n/a
 
      09-21-2005
Yes, I have read the perldoc,

is that put all the command to a command list then call exec ??

Thanks


"A. Sinan Unur" <> wrote in message
news:Xns96D88B1952B2asu1cornelledu@127.0.0.1...
> "Jianli Shen" <> wrote in
> news:dgqnvp$mgj$:
>
>> is that because: exec will not call the END block, nor will it call
>> any DESTROY method in the object ???

>
> perldoc -f exec
>
> exec LIST
> exec PROGRAM LIST
> The "exec" function executes a system command *and never
> returns* ...
>
> Read the documentation for more information.
>
> Have you seen the posting guidelines for this group?
>
> Sinan
> --
> A. Sinan Unur <>
> (reverse each component and remove .invalid for email address)
>
> comp.lang.perl.misc guidelines on the WWW:
> http://mail.augustmail.com/~tadmc/cl...uidelines.html



 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      09-21-2005
Jianli Shen wrote:
> I write the following script,
> hope it call "atouRcv -b ***** & " in each iteration.


How would that be? The program that is started via "exec" _replaces_ your
Perl program.
After calling exec once there is nothing left that could possibly iterate
anything.

> however, it only call once when $port=6811


Yeah, that's the documented behaviour of exec().

> is that because: exec will not call the END block, nor will it call
> any DESTROY method in the object ???


No, it is because a successful exec() never returns to begin with.

> how can I make this loop work ??


Use the proper tool. Maybe you were looking for system() instead?

jue


 
Reply With Quote
 
John W. Krahn
Guest
Posts: n/a
 
      09-21-2005
Jianli Shen wrote:
>
> I write the following script,
> hope it call "atouRcv -b ***** & " in each iteration.
> however, it only call once when $port=6811
>
> is that because: exec will not call the END block, nor will it call any
> DESTROY method in the object ???
>
> how can I make this loop work ??
>
>
> #!/usr/bin/perl
>
> my $port=6811;
> foreach my $r ( 0, 50, 200 ){
> foreach my $l (0, 0.01, 0.05){
> for (my $i=0; $i<=9; $i++) { #each run 10times
> exec "atouRcv -b 2000000 -r ". $r . " -l ". $l . " -p " . $port . " &
> ";
> $port += 1;
> }
> }
> }


Perhaps you want something like (UNTESTED):

#!/usr/bin/perl
use warnings;
use strict;

my $port = 6811;
for my $r ( 0, 50, 200 ) {
for my $l ( 0, 0.01, 0.05 ) {
for ( 1 .. 10 ) { # each run 10 times
defined( my $pid = fork ) or die "Cannot fork: $!";
$pid or exec 'atouRcv', '-b', 2000000, '-r', $r, '-l', $l, '-p', $port;
$port++;
}
}
}



John
--
use Perl;
program
fulfillment
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Runtime.exec(String[]) Doesn't Always Work, bBut Runtime.exec(String) Does Hal Vaughan Java 11 05-22-2006 04:49 PM
Exec/System call with spaces in exec path problem ... Random Task Perl Misc 12 12-04-2005 10:03 AM
exec "statement" VS. exec "statement" in globals(), locals() tedsuzman Python 2 07-21-2004 08:41 PM
Backup Exec 9.1: The Backup Exec job engine system service is not responding Christian Falch Computer Support 1 06-23-2004 02:22 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57