Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > system call problem under Win32

Reply
Thread Tools

system call problem under Win32

 
 
Uwe Huniar
Guest
Posts: n/a
 
      05-31-2006
I have a strange error with the combination of perl, java and Windows...

What we do:

- a java program calls (with runtime.exec) 'perl PATH/script.pl'

- in script.pl there are several system calls to binaries

- system "prog.exe >> out";

java and perl work as expected, the script.pl runs on the shell
(cmd.exe as well as bash with cygwin) without problems.
But the script.pl does not do the system call at all, it passes the
system " ... "; without executing the binary (also a simple echo or
'del file' does not work).

Error on:
Windows 2000, ActivePerl 5.8.8, Java2 1.5.0
Windows XP, ActivePerl 5.8.8, Java2 1.5.0
Windows XP, PXPerl 5.8.7-6, Java2 1.5.0

Works properly on:
Windows XP, cygwin perl 5.8.7, Java2 1.5.0

Anyone any idea how to circumvent that?

Uwe
 
Reply With Quote
 
 
 
 
Mothra
Guest
Posts: n/a
 
      05-31-2006
Uwe Huniar wrote:
> - system "prog.exe >> out";
>


Shame on you for not checking the return status of your system calls
From the docs:

You can check all the failure possibilities by inspecting $?
like this:

if ($? == -1) {
print "failed to execute: $!\n";
}
elsif ($? & 127) {
printf "child died with signal %d, %s coredump\n",
($? & 127), ($? & 12 ? 'with' : 'without';
}
else {
printf "child exited with value %d\n", $? >> 8;
}

Hope this helps

Mothra


 
Reply With Quote
 
 
 
 
xhoster@gmail.com
Guest
Posts: n/a
 
      05-31-2006
Uwe Huniar <(E-Mail Removed)-karlsruhe.de> wrote:
> I have a strange error with the combination of perl, java and Windows...
>
> What we do:
>
> - a java program calls (with runtime.exec) 'perl PATH/script.pl'
>
> - in script.pl there are several system calls to binaries
>
> - system "prog.exe >> out";


I have a radical idea. If you want to know why the "system" failed, why
not check to see why the "system" failed?


The return value is the exit status of the program
as returned by the "wait" call. To get the actual
exit value shift right by eight (see below). See
also "exec". ...
Return value
of -1 indicates a failure to start the program
(inspect $! for the reason).



Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
Uwe Huniar
Guest
Posts: n/a
 
      06-01-2006
Thanks for the nice answer, I have indeed forgotten to mention
that the return value tells me that the file or directory has
not been found.

The problem is that even if I give the full path to the executable
(and, as I told even a shell intrinsic like del or dir, and also
cmd.exe with full path) does not help. And, of course, I do a

if (-x $exec ) ... else die(...);
system "$exec >> $output";
print "exited with $? \n $! \n";

So the problem is that obviously it does not matter what I call with
'system', it seems that system itself does not run.

I am not a perl expert (unfortunately I am not a Windows or Java or
perl expert, but using the combination...) but my guess is that perl
tries to start some kind of a shell to start the given binary within
that shell. Seems that perl does not find the shell itself and thus
the return value is not related to the argument of sytem but to sytem
itself. Is that reasonable?

Since the perl script runs without problems when started from the
command line, it has something to do with the combination of
Java and perl. The only possible problem I know is the fact that
Java does not export all environment variables... but that is why
I set $ENV{PATH} 'by hand' at the beginning of the script (but it
does not make any difference if I do that or not).

Any help is welcome,

Uwe


http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Uwe Huniar <(E-Mail Removed)-karlsruhe.de> wrote:
>> I have a strange error with the combination of perl, java and Windows...
>>
>> What we do:
>>
>> - a java program calls (with runtime.exec) 'perl PATH/script.pl'
>>
>> - in script.pl there are several system calls to binaries
>>
>> - system "prog.exe >> out";


> I have a radical idea. If you want to know why the "system" failed, why
> not check to see why the "system" failed?



> The return value is the exit status of the program
> as returned by the "wait" call. To get the actual
> exit value shift right by eight (see below). See
> also "exec". ...
> Return value
> of -1 indicates a failure to start the program
> (inspect $! for the reason).




> Xho


> --
> -------------------- http://NewsReader.Com/ --------------------
> Usenet Newsgroup Service $9.95/Month 30GB


--

--------------------------------------------------------------------
Uwe Huniar |
COSMOlogic GmbH&Co.KG | Institut f. physikalische Chemie
Burscheider Str. 515 | Lehrstuhl fuer theoretische Chemie
D-51381 Leverkusen | Universitaet Karlsruhe
Germany | Kaiserstrasse 12
| D-76128 Karlsruhe / Germany
| Tel.: +49(0)721-608-2924
| Fax.: +49(0)721-608-7225
EMail: (E-Mail Removed)
(E-Mail Removed)
http://www.velocityreviews.com/forums/(E-Mail Removed)-karlsruhe.de
 
Reply With Quote
 
Dave
Guest
Posts: n/a
 
      06-01-2006

"Uwe Huniar" <(E-Mail Removed)-karlsruhe.de> wrote in message
news:e5mba4$mlj$(E-Mail Removed)-karlsruhe.de...
> Thanks for the nice answer, I have indeed forgotten to mention
> that the return value tells me that the file or directory has
> not been found.
>
> The problem is that even if I give the full path to the executable
> (and, as I told even a shell intrinsic like del or dir, and also
> cmd.exe with full path) does not help. And, of course, I do a
>
> if (-x $exec ) ... else die(...);
> system "$exec >> $output";
> print "exited with $? \n $! \n";
>
> So the problem is that obviously it does not matter what I call with
> 'system', it seems that system itself does not run.
>
> I am not a perl expert (unfortunately I am not a Windows or Java or
> perl expert, but using the combination...) but my guess is that perl
> tries to start some kind of a shell to start the given binary within
> that shell. Seems that perl does not find the shell itself and thus
> the return value is not related to the argument of sytem but to sytem
> itself. Is that reasonable?
>
> Since the perl script runs without problems when started from the
> command line, it has something to do with the combination of
> Java and perl. The only possible problem I know is the fact that
> Java does not export all environment variables... but that is why
> I set $ENV{PATH} 'by hand' at the beginning of the script (but it
> does not make any difference if I do that or not).
>
> Any help is welcome,
>
> Uwe
>
>
> (E-Mail Removed) wrote:
>> Uwe Huniar <(E-Mail Removed)-karlsruhe.de> wrote:
>>> I have a strange error with the combination of perl, java and Windows...
>>>
>>> What we do:
>>>
>>> - a java program calls (with runtime.exec) 'perl PATH/script.pl'
>>>
>>> - in script.pl there are several system calls to binaries
>>>
>>> - system "prog.exe >> out";

>
>> I have a radical idea. If you want to know why the "system" failed, why
>> not check to see why the "system" failed?

>
>
>> The return value is the exit status of the program
>> as returned by the "wait" call. To get the actual
>> exit value shift right by eight (see below). See
>> also "exec". ...
>> Return value
>> of -1 indicates a failure to start the program
>> (inspect $! for the reason).

>
>
>
>> Xho

>
>> --
>> -------------------- http://NewsReader.Com/ --------------------
>> Usenet Newsgroup Service $9.95/Month 30GB

>
> --
>
> --------------------------------------------------------------------
> Uwe Huniar |
> COSMOlogic GmbH&Co.KG | Institut f. physikalische Chemie
> Burscheider Str. 515 | Lehrstuhl fuer theoretische Chemie
> D-51381 Leverkusen | Universitaet Karlsruhe
> Germany | Kaiserstrasse 12
> | D-76128 Karlsruhe / Germany
> | Tel.: +49(0)721-608-2924
> | Fax.: +49(0)721-608-7225
> EMail: (E-Mail Removed)
> (E-Mail Removed)
> (E-Mail Removed)-karlsruhe.de



You will get better answers if you give us the actual code used (in a test
run - see 'short but complete script' in the posting guidelines) and the
actual error returned.



 
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
system call not working under cron Michael Satterwhite Ruby 9 05-07-2009 06:56 AM
Perl system call fails under windows 2003 server rahulkats@gmail.com Perl Misc 1 06-15-2007 10:00 AM
win32- system call - getting results back into python gregpinero@gmail.com Python 2 05-07-2005 07:20 PM
System reboot/system freeze with simple code in Visual C++ 6 and lcc-win32 (OS issue?) Wagner Dias C++ 3 03-28-2005 07:59 PM
Packing data for a win32 'C' style system call to Winamp. help please! Andy Perl 0 09-24-2003 01:18 PM



Advertisments