Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > ActiveState: Can't spawn "cmd.exe"?

Reply
Thread Tools

ActiveState: Can't spawn "cmd.exe"?

 
 
Daniel Pfeiffer
Guest
Posts: n/a
 
      06-12-2005
Hi,

I am a developer of makepp.sourceforge.net, a way enhanced (GNU) make
replacement. I have been busy these last weeks extending the Cygwin port
first to MinGW (the easy part) and then to ActiveState Perl, with just the
native Windows 2000 (no Unixy stuff around).

We have an extensive test suite. Most of what fails is related to test Shell
scripts, which are beyond the capabilities of the system call. These will
have to be ported to Perl (in which both makepp and the test harness are written).

But the test variable_expansion gives an error -1 when running a simple echo
command. And additional_tests/2003_10_11_idash is also baffling, with more
detailed analysis:

A rule excutes this command (with CC set to the first two words) on one line.
This single string gets passed to the system function:

echo nocc -g -I subdir1 -I- -Isubdir2 -c compilation_test.c -o compilation_test.o

This gives a warning (I installed a $SIG{__WARN__} locally around system):

Can't spawn "cmd.exe": No such file or directory at C:/TEMP/cvs/Rule.pm line 1128.

And system gives a return of 255 << 8. What could be causing this, and how
could it be evited?

NB: Passing the identical string to perl -e "system '...'" works just fine.

If this is not a known issue with ActiveState Perl (I tried both 5.6.1 and
5.8.6), I would be extremely glad for help by a Windows expert! This would
require picking up the latest makepp version from CVS.

thank you very much in advance!

coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn
Daniel Pfeiffer

--
lerne / learn / apprends / lär dig / ucz się Esperanto:
http://lernu.net/
 
Reply With Quote
 
 
 
 
Rick Measham
Guest
Posts: n/a
 
      06-13-2005
Daniel Pfeiffer wrote:
> Can't spawn "cmd.exe": No such file or directory at C:/TEMP/cvs/Rule.pm
> line 1128.


Can't be sure what/where your problem is, but cmd.exe is a Norton AV
file. Could be that your external execution is trying to be run through
cmd.exe, but is failing for some reason. Try getting rid of Norton and
run it again.

Cheers!
Rick Measham
 
Reply With Quote
 
 
 
 
Sisyphus
Guest
Posts: n/a
 
      06-13-2005

"Daniel Pfeiffer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I am a developer of makepp.sourceforge.net, a way enhanced (GNU) make
> replacement. I have been busy these last weeks extending the Cygwin port
> first to MinGW (the easy part) and then to ActiveState Perl, with just the
> native Windows 2000 (no Unixy stuff around).
>
> We have an extensive test suite. Most of what fails is related to test

Shell
> scripts, which are beyond the capabilities of the system call. These will
> have to be ported to Perl (in which both makepp and the test harness are

written).
>
> But the test variable_expansion gives an error -1 when running a simple

echo
> command. And additional_tests/2003_10_11_idash is also baffling, with

more
> detailed analysis:
>
> A rule excutes this command (with CC set to the first two words) on one

line.
> This single string gets passed to the system function:
>
> echo nocc -g -I subdir1 -I- -Isubdir2 -c compilation_test.c -o

compilation_test.o
>
> This gives a warning (I installed a $SIG{__WARN__} locally around system):
>
> Can't spawn "cmd.exe": No such file or directory at C:/TEMP/cvs/Rule.pm

line 1128.
>



I don't quite understand. Line 1128 of Rule.pm is:
system( format_exec_args( $action ));

Are you saying that there's no problem with that line on MinGW-built perl,
but there *is* a problem with that line on ActiveState perl ?

If so, then the solution would surely be to ensure that
'format_exec_args($action)' returns the same string with ActiveState perl as
it does for MinGW perl. (Or is that already the case ?)

Precisely what is the full string returned by 'format_exec_args($action)' ?
(I couldn't understand the meaning of "with CC set to the first two words".)

> And system gives a return of 255 << 8. What could be causing this, and

how
> could it be evited?
>
> NB: Passing the identical string to perl -e "system '...'" works just

fine.
>


The "identical string" is the string returned by 'format_exec_args($action)'
...... right ?
And it's working fine in the 'perl -e....' system call, but producing that
error when run from Rule.pm .... right ?

When testing with ActiveState perl what shell are you running in ?
When testing with MinGW perl what shell are you running in ?
Could it be that you're invoking the wrong shell without realising it?

I don't know how to generate the "Can't spawn cmd.exe" error. Anyone ?

Cheers,
Rob


 
Reply With Quote
 
Sisyphus
Guest
Posts: n/a
 
      06-13-2005

"Sisyphus" <(E-Mail Removed)> wrote in message
news:42acee17$0$16705$(E-Mail Removed) u...
>
> "Daniel Pfeiffer" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi,
> >
> > I am a developer of makepp.sourceforge.net, a way enhanced (GNU) make
> > replacement. I have been busy these last weeks extending the Cygwin

port
> > first to MinGW (the easy part) and then to ActiveState Perl, with just

the
> > native Windows 2000 (no Unixy stuff around).
> >
> > We have an extensive test suite. Most of what fails is related to test

> Shell
> > scripts, which are beyond the capabilities of the system call. These

will
> > have to be ported to Perl (in which both makepp and the test harness are

> written).
> >
> > But the test variable_expansion gives an error -1 when running a simple

> echo
> > command. And additional_tests/2003_10_11_idash is also baffling, with

> more
> > detailed analysis:
> >
> > A rule excutes this command (with CC set to the first two words) on one

> line.
> > This single string gets passed to the system function:
> >
> > echo nocc -g -I subdir1 -I- -Isubdir2 -c compilation_test.c -o

> compilation_test.o
> >
> > This gives a warning (I installed a $SIG{__WARN__} locally around

system):
> >
> > Can't spawn "cmd.exe": No such file or directory at C:/TEMP/cvs/Rule.pm

> line 1128.


[snip]

>
> I don't know how to generate the "Can't spawn cmd.exe" error. Anyone ?
>


Oh ... yes I do know how to generate that warning. Just run a system()
command in a shell that doesn't have the path to cmd.exe in its 'path'
environment variable.

eg:
#### test.pl####
use warnings;
system "dir";
__END__

And then, running in the cmd.exe shell:

F:\makepp>set path=

F:\makepp>path
PATH=(null)

F:\>D:\perl58_M\bin\perl -lwe "system 'dir'"
Can't spawn "cmd.exe": No such file or directory at -e line 1.

F:\>D:\perl58_M\bin\perl test.pl
Can't spawn "cmd.exe": No such file or directory at test.pl line 2.

F:\>

I probably need answers to the questions I asked in my earlier reply before
I could speculate further.

Cheers,
Rob


 
Reply With Quote
 
Sisyphus
Guest
Posts: n/a
 
      06-13-2005

"Rick Measham" <(E-Mail Removed)> wrote in message
news:d8ik8b$ofv$(E-Mail Removed)...
> Daniel Pfeiffer wrote:
> > Can't spawn "cmd.exe": No such file or directory at C:/TEMP/cvs/Rule.pm
> > line 1128.

>
> Can't be sure what/where your problem is, but cmd.exe is a Norton AV
> file. Could be that your external execution is trying to be run through
> cmd.exe, but is failing for some reason. Try getting rid of Norton and
> run it again.
>


'cmd.exe' is also the native Win32 shell program that ships with Windows
NT/2000/XP - and it's *that* cmd.exe (not the Norton file) that's being
sought.

Cheers,
Rob


 
Reply With Quote
 
Daniel Pfeiffer
Guest
Posts: n/a
 
      06-13-2005
la 13.06.2005 04:23 Sisyphus skribis:
> "Daniel Pfeiffer" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...


>> This single string gets passed to the system function:
>>
>>echo nocc -g -I subdir1 -I- -Isubdir2 -c compilation_test.c -o

>
> compilation_test.o
>
>>This gives a warning (I installed a $SIG{__WARN__} locally around system):
>>
>>Can't spawn "cmd.exe": No such file or directory at C:/TEMP/cvs/Rule.pm
>> line 1128.

>
>
>
> I don't quite understand. Line 1128 of Rule.pm is:
> system( format_exec_args( $action ));


format_exec_args is a workaround for Perl's buggy system function. When Perl
sees no special chars in the string it internally does a split on whitespace
and execs. But it misses some special characters and builtin commands. On
anything except ActiveState this function returns ('/bin/sh', '-c', $_[0]) in
such cases.

> Precisely what is the full string returned by 'format_exec_args($action)' ?


On ActiveState it returns the string verbatim.

> (I couldn't understand the meaning of "with CC set to the first two words".)


The make rule in question runs $(CC) ..., and since I'm not yet at the point
of messing with the weirdness of Windows compilers, I "set CC=echo nocc".

>>And system gives a return of 255 << 8. What could be causing this, and

>
> how
>
>>could it be evited?
>>
>>NB: Passing the identical string to perl -e "system '...'" works just

>
> fine.
>
>
> The "identical string" is the string returned by 'format_exec_args($action)'
> ..... right ?


Yes.

> And it's working fine in the 'perl -e....' system call, but producing that
> error when run from Rule.pm .... right ?


Yes.

> When testing with ActiveState perl what shell are you running in ?


Normal DOS command window, so I suppose cmd.exe.

> When testing with MinGW perl what shell are you running in ?


/usr/bin/sh which is MinGW's bash 2.04.

> Could it be that you're invoking the wrong shell without realising it?


Probably! In all three environments, I reduce the PATH to a minimum, so as to
not get any "goodies" from another environment. E.g. ActiveState would
happily pick up Unix commands from MKS, MinGW and Cygwin, so I do

set PATH=C:\WINNT\system32;C:\WINNT;C:\Perl\bin

The first directory contains CMD.EXE. (Which answers your 2nd post). The
funny thing is that when I don't reduce the PATH, something does happen. I
modified export.test to do

echo %X% %Y% >testfile

and then testfile contains the line "Syntaxfehler." (german for error), which
is not what happens when I type that command in the DOS window.

Thanks for taking so much time!
Daniel
 
Reply With Quote
 
Sisyphus
Guest
Posts: n/a
 
      06-13-2005

"Daniel Pfeiffer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> la 13.06.2005 04:23 Sisyphus skribis:
> > "Daniel Pfeiffer" <(E-Mail Removed)> wrote in message


> >
> > The "identical string" is the string returned by

'format_exec_args($action)'
> > ..... right ?

>
> Yes.
>
> > And it's working fine in the 'perl -e....' system call, but producing

that
> > error when run from Rule.pm .... right ?

>
> Yes.
>
> > When testing with ActiveState perl what shell are you running in ?

>
> Normal DOS command window, so I suppose cmd.exe.
>
> > When testing with MinGW perl what shell are you running in ?

>
> /usr/bin/sh which is MinGW's bash 2.04.
>


Normally, perl is built using MinGW in the cmd.exe shell, following the
instructions in the README.win32 (which involves editing the
Win32\makefile.mk). It's also normal to run that perl in the cmd.exe shell.
I believe it's quite a trivial thing to run MinGW-built perl (and
ActiveState perl, too) in a bash shell, though I've not personally done
that. Not sure why I'm mentioning this .... I guess it's just that the
reference to MinGW's bash shell makes me wonder whether you've built perl
with MinGW in some unusual way .... and if that's the case I'm further
wondering whether it should be brought to your attention

> > Could it be that you're invoking the wrong shell without realising it?

>
> Probably! In all three environments, I reduce the PATH to a minimum, so

as to
> not get any "goodies" from another environment. E.g. ActiveState would
> happily pick up Unix commands from MKS, MinGW and Cygwin, so I do
>
> set PATH=C:\WINNT\system32;C:\WINNT;C:\Perl\bin
>
> The first directory contains CMD.EXE. (Which answers your 2nd post).


That makes it very hard (for me) to work out why a system call that works
when invoked by 'perl -e ..' is unable to spawn the cmd.exe when called from
file (Rule.pm).

What happens if you run a script containing a system command (such as the
test.pl in my 2nd post) from that very same shell ? Does it fail to spawn
cmd.exe, too ?

Maybe:
#### test.pl ####
use warnings;
$ENV{PATH} = '';
system "cd";
__END__

D:\pscrpt>perl -lwe "system 'cd'"
D:\pscrpt

D:\pscrpt>perl try.pl
Can't spawn "cmd.exe": No such file or directory at try.pl line 3.

D:\pscrpt>perl -lwe "system 'cd'"
D:\pscrpt

That's one simple way of getting a system command to work with 'perl -e...'
but fail when called from file. Now, I'm not suggesting that Rule.pm
explicitly removes C:\winnt\system32 from the path - but could that be
happening somehow ??

I'll continue to puzzle over this, and post again if I think of something -
but it doesn't look like I'll be able to offer much help.

Maybe you could also try perlmonks if there's no useful help here.

Cheers,
Rob




 
Reply With Quote
 
Daniel Pfeiffer
Guest
Posts: n/a
 
      06-14-2005
la 13.06.2005 13:15 Sisyphus skribis:
> "Daniel Pfeiffer" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>>la 13.06.2005 04:23 Sisyphus skribis:
>>>When testing with MinGW perl what shell are you running in ?

>>
>>/usr/bin/sh which is MinGW's bash 2.04.

>
> Normally, perl is built using MinGW in the cmd.exe shell, following the
> instructions in the README.win32 (which involves editing the
> Win32\makefile.mk). It's also normal to run that perl in the cmd.exe shell.
> I believe it's quite a trivial thing to run MinGW-built perl (and
> ActiveState perl, too) in a bash shell, though I've not personally done
> that. Not sure why I'm mentioning this .... I guess it's just that the
> reference to MinGW's bash shell makes me wonder whether you've built perl
> with MinGW in some unusual way .... and if that's the case I'm further
> wondering whether it should be brought to your attention


I had a hard time getting MinGW together, even though Msys is supposed to give
all you need. I picked up a lot of packages, before I finally had a Perl.
It's the Perl 5.6.1 they deliver on their server. I compiled nothing myself.

>>>Could it be that you're invoking the wrong shell without realising it?

>>
>>Probably! In all three environments, I reduce the PATH to a minimum, so

>
> as to
>
>>not get any "goodies" from another environment. E.g. ActiveState would
>>happily pick up Unix commands from MKS, MinGW and Cygwin, so I do
>>
>>set PATH=C:\WINNT\system32;C:\WINNT;C:\Perl\bin
>>
>>The first directory contains CMD.EXE. (Which answers your 2nd post).


I finally sorted this one out. Coming from Unix, makepp assumes PATH to be
colon separated and splits it on that. I haven't tracked where it gets put
together again (after all we still have the full PATH intact as well) but
splitting it on ';' and stripping the quotes has solved the cmd.exe problem

So now finally makepp works on Windows. The remaining issues are to teach it
to parse typical Windows compiler invocations, because it figures out implicit
dependencies from -I and -l/-L options, such that you don't need makedep.

It would also be great to have it implicitly add .exe, such that you don't
need separate handling of Windows targets, and being case-preserving on file
names, rather than lowercasing everything. These issues can be a bit tricky,
because makepp knows about potential files from the rules, even before they
actually exist, but then it can only guess these things.

Thanks again for all your support!
Daniel
 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      06-14-2005
Daniel Pfeiffer <(E-Mail Removed)> wrote in
news:(E-Mail Removed):
> Coming from Unix, makepp assumes PATH to be colon separated and
> splits it on that.


And what is your excuse for not using File::Spec?

> I haven't tracked where it gets put together again


Very confidence inspiring.

Indeed, these posts have helped me decide never to give makepp a shot.

> but splitting it on ';'


Oh yeah! Repeat again, what is your excuse for not using File::Spec?

<URL: http://search.cpan.org/~kwilliams/PathTools-3.08/lib/File/Spec.pm>

File::Spec - portably perform operations on file names

> and stripping the quotes has solved the cmd.exe problem


And probably introduced a bunch more given the haphazard way you are
approaching this.

Sinan

--
A. Sinan Unur <(E-Mail Removed)>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html
 
Reply With Quote
 
Sisyphus
Guest
Posts: n/a
 
      06-15-2005

"Daniel Pfeiffer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

[snip]

> I had a hard time getting MinGW together, even though Msys is supposed to

give
> all you need. I picked up a lot of packages, before I finally had a Perl.
> It's the Perl 5.6.1 they deliver on their server. I compiled nothing

myself.

Aaah - that would have been a perl package that came with one of the
"extras" MSYS packages - probably msysDTK I'm guessing.
Fyi: I don't know of anyone actually using that perl build - and had
forgotten that I had read of its existence. Needless to say, I haven't
actually tried it out. It sounds like it has a particularly nixy flavour
(similar to Cygwin's perl ?). Any people I know of who are using MinGW-built
perl built it as I outlined in my last post. That way you get a native Win32
perl - same as ActiveState perl, but built with the MinGW port of the gcc
compiler. Built that way, MinGW perl and ActiveState perl are binary
compatible (assuming the MinGW perl has been built, like ActiveState perl,
with threads support). I doubt that you could swap binaries around between
your MinGW perl and an ActiveState perl 5.6 (even if your MinGW perl *is*
multithreaded).

Cheers,
Rob


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Logging stdout/stderr/stdin of an spawn process (Open4::spawn) Edgardo Hames Ruby 1 05-06-2008 08:17 PM
Logging stdout/stderr/stdin of an spawn process (Open4::spawn) Ed Hames Ruby 0 04-16-2008 04:21 PM
spawn syntax + os.P_WAIT mode behavior + spawn stdout redirection Derek Basch Python 2 01-21-2005 05:37 AM
Best Practice to spawn an Application from a Web Service ? Paul ASP .Net 3 10-13-2003 08:13 AM
When I spawn a lightweight process in ASP.NET Does it time out?? MS News ASP .Net 2 07-31-2003 11:53 PM



Advertisments