Click here to get back home

Problem in using Win32::Process::Create

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Problem in using Win32::Process::Create sachin 07-24-2007
Posted by sachin on July 24, 2007, 6:25 am
Please log in for more thread options


Hi All
I am new to perl programming.
I am trying to call one of my exe using Create function present in
Win32::Process.
Following is the code I have written,
********************************************************************************************
use Win32::Process;
use Win32;

$GPIBPath = "C:\Project\GPIB\GPIB.V2\bin\GPIB.exe";
@GPIBArg = ("5","3.2","10","2","1");

Win32::Process::Create($GPIBObj,
$GPIBPath,
@GPIBArg,
0,
NORMAL_PRIORITY_CLASS,
".") || die ErrorReport();

$GPIBObj->Wait(INFINITE);

sub ErrorReport{
print Win32::FormatMessage( Win32::GetLastError() );
}
**********************************************************************************************
When I execute this pl file using command prompt, i get the following
error
Usage: Win32::Process::Create(cP , appname , cmdline , inherit ,
flags , curdir) at file_handling.pl line 7

I have checked that process.pm module is available at the path C:\perl
\lib\win32 and C:\perl\site\lib\win32.


Can anyone please help me regarding this problem.
Thanks in advance.


Posted by Sisyphus on July 24, 2007, 7:06 am
Please log in for more thread options



.
.
> Following is the code I have written,
>
********************************************************************************************
> use Win32::Process;
> use Win32;
>
> $GPIBPath = "C:\Project\GPIB\GPIB.V2\bin\GPIB.exe";
> @GPIBArg = ("5","3.2","10","2","1");
>
> Win32::Process::Create($GPIBObj,
> $GPIBPath,
> @GPIBArg,
> 0,
> NORMAL_PRIORITY_CLASS,
> ".") || die ErrorReport();
>
> $GPIBObj->Wait(INFINITE);
>
> sub ErrorReport{
> print Win32::FormatMessage( Win32::GetLastError() );
> }
>
**********************************************************************************************
> When I execute this pl file using command prompt, i get the following
> error
> Usage: Win32::Process::Create(cP , appname , cmdline , inherit ,
> flags , curdir) at file_handling.pl line 7
>

When you get a "Usage: ..." error, that generally means there is something
wrong with the arguments you supplied.
In this case it's the third argument (@GPIBArg) that's the problem.
I think that replacing that third arg to Win32::Process::Create() with
either:
"GPIB @GPIBArg",
or
"$GPIBPath @GPIBArg",
or
"GPIB 5 3.2 10 2 1",
or
"$GPIBPath 5 3.2 10 2 1",
should work.

See the example given at the start of 'perldoc Win32::Process'. Note that
the 3rd arg needs to be the actual command line command that you want to
run.
It's one of the strange quirks of Win32::Process that the 3rd arg needs to
repeat something that can be derived from the 2nd arg.

Cheers,
Rob


Posted by sachin on July 31, 2007, 1:09 am
Please log in for more thread options


>
> .
> .
>
>
>
>
>
> > Following is the code I have written,
> > ***********************************************************************=
****=AD*****************
> > use Win32::Process;
> > use Win32;
>
> > $GPIBPath =3D "C:\Project\GPIB\GPIB.V2\bin\GPIB.exe";
> > @GPIBArg =3D ("5","3.2","10","2","1");
>
> > Win32::Process::Create($GPIBObj,
> > $GPIBPath,
> > @GPIBArg,
> > 0,
> > NORMAL_PRIORITY_CLASS,
> > ".") || die ErrorReport();
>
> > $GPIBObj->Wait(INFINITE);
>
> > sub ErrorReport{
> > print Win32::FormatMessage( Win32::GetLastError() );
> > }
> > ***********************************************************************=
****=AD*******************
> > When I execute this pl file using command prompt, i get the following
> > error
> > Usage: Win32::Process::Create(cP , appname , cmdline , inherit ,
> > flags , curdir) at file_handling.pl line 7
>
> When you get a "Usage: ..." error, that generally means there is something
> wrong with the arguments you supplied.
> In this case it's the third argument (@GPIBArg) that's the problem.
> I think that replacing that third arg to Win32::Process::Create() with
> either:
> "GPIB @GPIBArg",
> or
> "$GPIBPath @GPIBArg",
> or
> "GPIB 5 3.2 10 2 1",
> or
> "$GPIBPath 5 3.2 10 2 1",
> should work.
>
> See the example given at the start of 'perldoc Win32::Process'. Note that
> the 3rd arg needs to be the actual command line command that you want to
> run.
> It's one of the strange quirks of Win32::Process that the 3rd arg needs to
> repeat something that can be derived from the 2nd arg.
>
> Cheers,
> Rob- Hide quoted text -
>
> - Show quoted text -




Thanks for your advice.
I have used the following parameter sequence.
$GPIBPath =3D "5 3.2 10 2 1";
And it is running fine.


Similar ThreadsPosted
Win32::Process::Create(vxsim) cmd line argument trouble December 17, 2007, 9:05 am
Win32::Process, SetProcessAffinityMask for an existing process = perl crash May 7, 2006, 6:22 pm
Win32::Process Kill Process in Windows ME April 13, 2005, 1:49 am
Image::Magick::Thumbnail::create problem September 24, 2004, 6:14 pm
problem using swig to create perl module October 6, 2005, 8:10 am
PDF::Create (or alike) to create watermark for existing pdf file? June 11, 2006, 6:18 pm
Win32::API problem... May 25, 2005, 5:33 pm
Problem installing win32::OLE September 20, 2005, 12:52 pm
win32::ie::mechanize PROBLEM December 10, 2004, 7:06 am
problem in using win32::SerialPort September 7, 2007, 2:27 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap