Solved

Using Perl system function to execute .exe file, getting error 32768

Posted on 2007-12-06
14
3,738 Views
Last Modified: 2013-12-25
Hi,
   I have a Perl script that runs in Microsoft IIS server as a CGI script, and does the following:

1) Reads stuff from the database,
2) Creates a plain text file to describe some data on the local disk (same folder)
3) and uses the "system" sub-routine to execute an external program that creates an image of the database data, like this:

my $error_code=system("<path to executable>  <parameters, including output image file name>");

However, the image does not show up on the resulting web page, and is never created on the disk -- the web page says Perl has an error of "32768". Also, what's interesting is that the plain text file DOES get created, but the image file doesn't, so it means Perl has no problems writing to disk, but cannot get the external executable to run and create the file...

Does anyone have idea idea what the error code 32768 means in Perl, and how to resolve this?
0
Comment
Question by:Envoy2064
  • 6
  • 3
  • 2
  • +2
14 Comments
 
LVL 18

Expert Comment

by:Morcalavin
Comment Utility
my $error_code=system("<path to executable>  <parameters, including output image file name>");

Can you give more info on this line?  What is the executable path?  Are you escaping special characters \ $, etc
0
 

Author Comment

by:Envoy2064
Comment Utility
It goes like this:

"d:/myfolder/myexe -Paramter1 d:/myfolder/outputfilename.png"
0
 

Author Comment

by:Envoy2064
Comment Utility
the "/" instead of "\" should not create any problems...
0
 
LVL 18

Expert Comment

by:Morcalavin
Comment Utility
Does the user that runs IIS have permission to execute programs?
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
In a system call in DOS, "/" instead of "\\" can create problems
0
 
LVL 18

Assisted Solution

by:Morcalavin
Morcalavin earned 100 total points
Comment Utility
This part probably works fine:
d:/myfolder/myexe

perl understands that / equals \ for this filesystem

This part probably bombs:
-Paramter1 d:/myfolder/outputfilename.png
myexe doesn't understand that / = \

Try
"d:/myfolder/myexe -Paramter1 d:\\myfolder\\outputfilename.png"
0
 

Author Comment

by:Envoy2064
Comment Utility
ozo, Morcalvin...thanks -- i'll try it out tomorrow as the server is not available at the moment.

Yes, we configured the IIS to let it execute scripts and executables, and read/write both...do you have any advice on giving IIS the absolute minimum permission but also let the application write to disk?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 48

Accepted Solution

by:
Tintin earned 125 total points
Comment Utility
It's not Perl that recognises forward or backslashes, it's the OS.  Windows recognises forward slashes just fine, it's the Windows command interpreter that doesn't like them.

As for the error code 32768, it's not Perl that would be generating that error, it will be the executable your are calling and/or IIS.
0
 

Author Comment

by:Envoy2064
Comment Utility
hm, i tried the \\ code, and it still doesn't work...any ideas? :-(
0
 

Author Comment

by:Envoy2064
Comment Utility
upped the point value to 450
0
 
LVL 28

Assisted Solution

by:FishMonger
FishMonger earned 100 total points
Comment Utility
Try this:

# my @cmd = ('d:/myfolder/myexe', '-Paramter1', 'd:/myfolder/outputfilename.png');

my @cmd = ('d:\myfolder\myexe', '-Paramter1', 'd:\myfolder\outputfilename.png');
 

system(@cmd) == 0 or die "system @args failed: $?"

Open in new window

0
 
LVL 28

Expert Comment

by:FishMonger
Comment Utility
system(@cmd) == 0 or die "system @args failed: $?"

should be
system(@cmd) == 0 or die "system @cmd failed: $?"

Also, I didn't test which path separator would be needed, so you may need to adjust that.
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 125 total points
Comment Utility
what happens when it doesn't work?
what is the normal way for  d:/myfolder/myexe to deal with errors?
and are you sure the Perl code is getting to the system call?
0
 

Author Comment

by:Envoy2064
Comment Utility
solved it...apparently there are DLL missing when I tested in via cmd.exe...
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Configure WPAD via DNS 3 50
Add Server Certificate in IIS from C# 6 68
can not add ASP.NET to IIS 8 26
Disk Ram Peak 1 12
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now