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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: cannot open: No such file or directory

Status
Not open for further replies.

willct

Programmer
Oct 4, 2005
17
US
I would like to run a perl script within another perl scirpt. The second perl script parses out data. When i use the print command it works fine, however when i use the perl script i get an error ===> Error cannot open: No such file or directory. what am i doing wrong.


thanks in advance!

#!/usr/bin/perl -w

my $source_dir = "/usr/local/sysadm/logs/monitor/carolina/cgt";
my $perl_dir = "/usr/local/sysadm/logs/monitor/carolina/";
opendir( DIR, $source_dir ) || die "Can't open files_out/o directory\n";
local( @filenames ) = readdir( DIR );
closedir( DIR ) || die "Can't close directory\n";

print "Original files:\n";

foreach $filename ( @filenames )
{
next if ($filename =~ m/^\./);
#print "$filename\n";
system( "$perl_dir/pro-monitorcsv.pl $filename" ) ;
}
 

my $perl_dir = "/usr/local/sysadm/logs/monitor/carolina/";

system ("$perl_dir/pro-monitorcsv.pl xxx) --> NOTE THE extra "/" which is already defiled in your var.
 
where do you get that error in the code you posted? You have no included $! in any of the die commands so that error would not be generated from the code you posted. Maybe it's coming from the other script you run using the system command.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
I like to use backticks instead of system for my sys calls :)
@out = `/path/to/file`;

then you can print @out if needed.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Yes, if there is return data backtiks or qx//. Not sure if that is the case here though.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
He said the second script parses out data. So by out I assumed he meant it was going to be returned to the original script. But I might be mistaken.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Hopefully he lets us know [smile]

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top