It's all about the answers!

Ask a question

Perl script in Project step not executing


Gabriel Orce (1122) | asked Mar 24 '11, 1:48 a.m.
Hi, I have a perl script that is inside a project step (i.e., not called from the step; the step itself is actually written in Perl). When i execute the job, i can see the script is part of the output, but it apparently is never executed. Here is part of the job output:


164 3/24/11 12:00 AM SCRIPT exit(1);
165 3/24/11 12:00 AM SCRIPT }
166 3/24/11 12:00 AM SCRIPT }
167 3/24/11 12:00 AM SCRIPT
168 3/24/11 12:00 AM SCRIPT open( OUT, ">$servers" ) or die "ERROR - Can't open $servers";
169 3/24/11 12:00 AM SCRIPT for (@Dest) { print OUT $_, "\\\n"; }
170 3/24/11 12:00 AM SCRIPT close(OUT);
171 3/24/11 12:00 AM EXEC start
172 3/24/11 12:00 AM EXEC /tmp/bfD-qeia syntax OK
173 3/24/11 12:00 AM EXEC end


It seems to only be checking the script's syntax (if i add any errors to it, the syntax does not show as OK).
Any ideas on why it is not executing?

Thanks in advance.

4 answers



permanent link
Brent Ulbricht (2.5k11) | answered Mar 28 '11, 1:22 p.m.
JAZZ DEVELOPER
Hi, I have a perl script that is inside a project step (i.e., not called from the step; the step itself is actually written in Perl). When i execute the job, i can see the script is part of the output, but it apparently is never executed. Here is part of the job output:


164 3/24/11 12:00 AM SCRIPT exit(1);
165 3/24/11 12:00 AM SCRIPT }
166 3/24/11 12:00 AM SCRIPT }
167 3/24/11 12:00 AM SCRIPT
168 3/24/11 12:00 AM SCRIPT open( OUT, ">$servers" ) or die "ERROR - Can't open $servers";
169 3/24/11 12:00 AM SCRIPT for (@Dest) { print OUT $_, "\\\n"; }
170 3/24/11 12:00 AM SCRIPT close(OUT);
171 3/24/11 12:00 AM EXEC start

172 3/24/11 12:00 AM EXEC /tmp/bfD-qeia syntax OK
173 3/24/11 12:00 AM EXEC end


It seems to only be checking the script's syntax (if i add any errors to it, the syntax does not show as OK).
Any ideas on why it is not executing?

Thanks in advance.

Hi,

It might help in diagnosis if you could paste the content of the step. If it's confidential, then just something representative.

Brent Ulbricht
Developer/Lead - RTC Build

permanent link
Gabriel Orce (1122) | answered Mar 28 '11, 5:04 p.m.
the code is just a Perl script. If i place an error in it, line 172 shows as "code had compilation errors" or something like that. So it is basically acting as a syntax checker rather than executing the code.
I have simplified the problem even more, after creating a simple step and adding it to the project, see below.

Step command:

#!/usr/bin/perl
print "Perl Variable: HELLO";


and its output:

...

265 3/28/11 4:01 PM EXEC Performing variable expansion on command line
266 3/28/11 4:01 PM EXEC ClearCase view set to 'fact_test'
267 3/28/11 4:01 PM EXEC spawning shell
268 3/28/11 4:01 PM SCRIPT #!/usr/bin/perl
269 3/28/11 4:01 PM SCRIPT
270 3/28/11 4:01 PM SCRIPT print "Perl Variable: HELLO";
271 3/28/11 4:01 PM EXEC start
272 3/28/11 4:01 PM EXEC /tmp/bfGZAoMa syntax OK
273 3/28/11 4:01 PM EXEC end
274 3/28/11 4:01 PM RESULT 0 (0)


thanks

permanent link
Tim McDaniel (401146) | answered Mar 28 '11, 5:52 p.m.
In article <imqtc0>,
bjornox <gabrielorce> wrote:
the code is just a Perl script. If i place an error in it, line 172
shows as "code had compilation errors" or something like
that. So it is basically acting as a syntax checker rather than
executing the code.
I have simplified the problem even more, after creating a simple step
and adding it to the project, see below.

Step command:

#!/usr/bin/perl
print "Perl Variable: HELLO";


and its output:

..

265 3/28/11 4:01 PM EXEC Performing variable expansion on command
line
266 3/28/11 4:01 PM EXEC ClearCase view set to 'fact_test'
267 3/28/11 4:01 PM EXEC spawning shell
268 3/28/11 4:01 PM SCRIPT #!/usr/bin/perl
269 3/28/11 4:01 PM SCRIPT
270 3/28/11 4:01 PM SCRIPT print "Perl Variable: HELLO";
271 3/28/11 4:01 PM EXEC start

272 3/28/11 4:01 PM EXEC /tmp/bfGZAoMa syntax OK
273 3/28/11 4:01 PM EXEC end
274 3/28/11 4:01 PM RESULT 0 (0)

I see from the Perl man page

-c causes Perl to check the syntax of the program and then exit
without executing it. Actually, it will execute "BEGIN",
"UNITCHECK", "CHECK", and "use" blocks, because these are
considered as occurring outside the execution of your
program. "INIT" and "END" blocks, however, will be skipped.

And this was my test:

$ perl -c -e 'print "Perl Variable: HELLO";'
-e syntax OK

I don't suppose Build Forge passes "-c" to every command interpreter
that it starts? Because that would be really bad.

I also considered

PERL5OPT Command-line options (switches). Switches in this
variable are taken as if they were on every Perl command line.
Only the - switches are allowed. ...

but notice the last sentence, that it doesn't obey -c.

Anyway, it appears from the man page that you have a workaround.

$COMPILING
$^C

The current value of the flag associated with the -c switch.
Mainly of use with -MO=... to allow code to alter its behavior
when being compiled, such as for example to AUTOLOAD at
compile time rather than normal, deferred loading. Setting
"$^C = 1" is similar to calling "B::minus_c".

$^C is three characters: dollar sign, caret, capital C.

My test:

$ perl -c -e 'BEGIN {$C = 0;} print "Hello\n"'
-e syntax OK
$ perl -c -e 'BEGIN {$^C = 0;} print "Hello\n"'
Hello

--
Tim McDaniel, tmcd@panix.com

Comments
Jojie Valiente commented Jul 23 '13, 2:34 a.m.

Hi Tim,

How can I apply this to a step running in Windows?

Cheers,

Jojie


permanent link
Jeffrey Gordon (961310) | answered Apr 20 '11, 5:01 p.m.
I have this exact same problem with an agent on AIX. The cause of the problem for me is having the CLEARCASE_VIEW environment variable defined.

If I take that environment variable out then Perl executes the script. But when it's defined Perl just checks the syntax. Support is working to recreate the issue for my PMR.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.