Apache, perl and WinXP cmd.exe - problem with percent sign in arg list

  • Thread starter Bartek Lakomiec
  • Start date
B

Bartek Lakomiec

Hi everybody,

I'm using Windows XP, ActivePerl 5.8, Apache HTTP server 2.2.3, and
I'm in a trouble with the following piece of code (let's call it
"my_code.pl") which calls "cleartool" application to dump some data
into a temporary file (to be used later):

my $arg = ...;
my $temp_output_filename = ...;
my $cmd = "c:\\windows\\system32\\cmd.exe /c \"cleartool descr -fmt %c
" . $arg " >$temp_output_filename \"";
ret = system($cmd);

It works fine when I execute it as "perl my_code.pl" - the result is
the same as when I paste "cleartool..." in a command window.

The code fails and generates "Cannot spawn cmd.exe" error when I try
to execute it from a website. By trials and errors I concluded the
reason for that is "-fmt %c". I tried some possible ways of escaping
the percent sign, and it doesn't help.

Will appreciate any comments on possible reasons/solutions.

--BL
 
B

Bartek Lakomiec

The lines I enclosed are not a complete program, and are meant to
illustrate the problem.

I will be gratefull for any comments on invoking perl's system()
function and Apache/perl/cmd.exe cooperation.

Thanx
--BL
 
J

Jürgen Exner

Bartek said:
On 2 Kwi, 17:06, Purl Gurl <[email protected]> wrote:

Oh, it is back. It is back. Amazing! Haven't seen it in a long time.

Absolutely agree. Use of global variables usually indicate poor coding
style.

Which of course is utter nonsense. But what would you expect from it.

jue
 
T

Thrill5

Bartek Lakomiec said:
Hi everybody,

I'm using Windows XP, ActivePerl 5.8, Apache HTTP server 2.2.3, and
I'm in a trouble with the following piece of code (let's call it
"my_code.pl") which calls "cleartool" application to dump some data
into a temporary file (to be used later):

my $arg = ...;
my $temp_output_filename = ...;
my $cmd = "c:\\windows\\system32\\cmd.exe /c \"cleartool descr -fmt %c
" . $arg " >$temp_output_filename \"";
ret = system($cmd);

It works fine when I execute it as "perl my_code.pl" - the result is
the same as when I paste "cleartool..." in a command window.

The code fails and generates "Cannot spawn cmd.exe" error when I try
to execute it from a website. By trials and errors I concluded the
reason for that is "-fmt %c". I tried some possible ways of escaping
the percent sign, and it doesn't help.

Will appreciate any comments on possible reasons/solutions.

--BL

Had the same problem on an IIS server. The problem is that apache can't
find cmd.exe. Yes it's in your %windows%\system32 directory, but apache
doesn't know that. To fix, you need to put cmd.exe in the some directory
that apache has access to and add that directory to PATH environment
variable for the account that is running apache. To verify that this is
your problem, the result returned by "system" is 255.

Scott
 
E

Eric Schwartz

Bartek Lakomiec said:
I'm using Windows XP, ActivePerl 5.8, Apache HTTP server 2.2.3, and
I'm in a trouble with the following piece of code (let's call it
"my_code.pl") which calls "cleartool" application to dump some data
into a temporary file (to be used later):

In addition to all the other replies, let me point you towards the
various ClearCase modules on CPAN, including
ClearCase::proc::ClearTool, which may be a cleaner and more direct way
to get at cleartool output. It was most recently updated on 26 March
2007, so it's apparently being currently maintained.

-=Eric
 

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

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top