CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
system command


New User

Sep 27, 2011, 5:45 AM

Post #1 of 4 (371 views)
system command Can't Post

I have to repeat a NS2 simulation a number of times, each time changing the number of network nodes, and calculate an average. Tcl script creates a file named "winfile" after the execution. The perl script is


for($i=2; $i<=10;$i++){

system ("ns tesina.tcl $i");

open (DATA,"<$winfile")
|| die "Can't open $winfile $!";

while (<DATA>) {
@x=split(' ');

print STDOUT "$i $average\n";

close DATA;

but when I run it tells me can not open the file, despite being created from the execution of the tcl files. By modifying the file in this way


it works. but I always get the same average value, which is impossible. It seems that the script does not run tcl but analyze a file previously created.
how can I fix that?

(This post was edited by robertodb on Sep 27, 2011, 5:49 AM)


Sep 27, 2011, 7:50 AM

Post #2 of 4 (364 views)
Re: [robertodb] system command [In reply to] Can't Post

Is this really the *complete* program, which you have posted? If this is the case, proceed as follows:

(1) Please add

use strict;
use warnings FATAL => qw(all);

on top of your program and re-run it

(2) If it dies, post the complete error message

Veteran / Moderator

Sep 27, 2011, 7:57 AM

Post #3 of 4 (363 views)
Re: [robertodb] system command [In reply to] Can't Post

Check the return code of the system call to see if it was successful.

See: perldoc -f system

New User

Sep 28, 2011, 2:49 AM

Post #4 of 4 (354 views)
Re: [FishMonger] system command [In reply to] Can't Post

ok guys...I've fixed it. I've changed the system statement in this way

system ("./ns tesina.ns $i")

anyway thank you so much


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives