system fails

P

Petterson Mikael

Hi,

I am executing the following perl script:

my @args = ("${arc_bin}/addproj", "-p $project", "-r $release", "-i
$isit");
system(@args) == 0 or die "could not execute $!";

The scalars are set to:

$project = 'espresso';
$release = 'rbssw/1.3';
$isit = '3.0';

In the perl script 'addproj' there is a validate method that takes 3
args. ( I don't have access to edit the script).

I get the following error message.

/app/arc/latest/bin/addproj: project/subproject/isit does not exist
system /app/arc/latest/bin/addproj -p espresso -r rbssw/1.3 -i 3.0
failed: 256 at /home/eraonel/dtest/dtest_perl-0.1/run_dtest.pl line 162.
In the subroutine there is check for directories. I have checked and
they exist. Any ideas why the system fails?

//Mikael


validate in addproj
--------------------------------------
f (! &validateproject($project, $release, $isit)) {
print STDERR "$0: project/subproject/isit does not exist\n";
exit 1;
}


sub validateproject
--------------------------------------
sub validateproject {
local $p=$_[0]; # project
local $r=$_[1]; # release
local $ir=$_[2];# isit
if ($p ne "" && $r ne "") { # Project & Release loaded
return $false if (! -d "$basedir/$p/$r");
}

return $false if (! -d "$basedir/isit/$ir");
return ($true);
}
 
J

Jim Keenan

Petterson said:
Hi,

I am executing the following perl script:

my @args = ("${arc_bin}/addproj", "-p $project", "-r $release", "-i
$isit");
system(@args) == 0 or die "could not execute $!";
[snip]

In the perl script 'addproj' there is a validate method that takes 3
args. ( I don't have access to edit the script).

I get the following error message.

/app/arc/latest/bin/addproj: project/subproject/isit does not exist
system /app/arc/latest/bin/addproj -p espresso -r rbssw/1.3 -i 3.0
failed: 256 at /home/eraonel/dtest/dtest_perl-0.1/run_dtest.pl line 162.
In the subroutine there is check for directories. I have checked and
they exist. Any ideas why the system fails?
At the risk of stating the obvious, 'system' is trying to execute
'addproj', which is giving an error. You indicate you don't have
'write' access to to 'addproj'; do you at least have 'read' access?
Otherwise, you're probably out of luck.

[snip]
sub validateproject
--------------------------------------
sub validateproject {
local $p=$_[0]; # project
local $r=$_[1]; # release
local $ir=$_[2];# isit

(This doesn't answer your main question, but someone is sure to point
it out anyway.) See 'perldoc -q lexical' on why you should use 'my'
instead of 'local' to lexically scope these variables. And, better
still, use an array to pull all 3 variables in at once.
 
A

Arndt Jonasson

Petterson Mikael said:
I am executing the following perl script:

my @args = ("${arc_bin}/addproj", "-p $project", "-r $release", "-i
$isit");
system(@args) == 0 or die "could not execute $!";

The scalars are set to:

$project = 'espresso';
$release = 'rbssw/1.3';
$isit = '3.0';

In the perl script 'addproj' there is a validate method that takes 3
args. ( I don't have access to edit the script).

I get the following error message.

/app/arc/latest/bin/addproj: project/subproject/isit does not exist
system /app/arc/latest/bin/addproj -p espresso -r rbssw/1.3 -i 3.0
failed: 256 at /home/eraonel/dtest/dtest_perl-0.1/run_dtest.pl line
162.

Maybe something interesting can be seen on line 162 in that script,
but my first suspicion is that the argument list @args does not
contain what you want. Look at the first paragraph in the description
of 'system'. With your code, "-p espresso" will become _one_ argument,
not two.

Try
my @args = ("${arc_bin}/addproj -p $project -r $release -i $isit");
instead.
 
T

Tad McClellan

Petterson Mikael said:
my @args = ("${arc_bin}/addproj", "-p $project", "-r $release", "-i
$isit");
system(@args) == 0 or die "could not execute $!";


You have more than one argument per list element.

my @args = ("${arc_bin}/addproj", '-p', $project, '-r', $release,
'-i', $isit);

sub validateproject {
local $p=$_[0]; # project
local $r=$_[1]; # release
local $ir=$_[2];# isit


Why are you using package variables rather than lexical variables?
 
A

Anno Siegel

Tad McClellan said:
sub validateproject {
local $p=$_[0]; # project
local $r=$_[1]; # release
local $ir=$_[2];# isit


Why are you using package variables rather than lexical variables?

That's part of the given system, outside OP's control. From what I've
seen, it's a Perl 4 program. There isn't enough of it to say if it's good
Perl 4 code. The use of "$true" and "$false" for booleans is not a good
sign.

Anno
 
A

Alfred Z. Newmane

Arndt said:
Maybe something interesting can be seen on line 162 in that script,
but my first suspicion is that the argument list @args does not
contain what you want. Look at the first paragraph in the description
of 'system'. With your code, "-p espresso" will become _one_ argument,
not two.

Try
my @args = ("${arc_bin}/addproj -p $project -r $release -i $isit");
instead.

Actually it should bt my $args (or $cmd, by convention), that is, a
scalar, not an array.
 
C

Chris Mattern

Anno said:
Tad McClellan said:
sub validateproject {
local $p=$_[0]; # project
local $r=$_[1]; # release
local $ir=$_[2];# isit


Why are you using package variables rather than lexical variables?

That's part of the given system, outside OP's control. From what I've
seen, it's a Perl 4 program. There isn't enough of it to say if it's good
Perl 4 code. The use of "$true" and "$false" for booleans is not a good
sign.
Frankly, the fact that it's Perl 4 code is not a good sign. All too
often, it's Perl 4 not because the author was actually coding for
Perl 4, but because he was copying Perl 4 code he didn't understand.
--
Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,282
Latest member
RoseannaBa

Latest Threads

Top