Problem in using Win32::Process::Create

Problem in using Win32::Process::Create

am 24.07.2007 12:25:19 von Sachin

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.

Re: Problem in using Win32::Process::Create

am 24.07.2007 13:06:26 von Sisyphus

"sachin" wrote in message
news:1185272719.207893.142110@r34g2000hsd.googlegroups.com.. .
..
..
> 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

Re: Problem in using Win32::Process::Create

am 31.07.2007 07:09:39 von Sachin

On Jul 24, 4:06 pm, "Sisyphus" wrote:
> "sachin" wrote in message
>
> news:1185272719.207893.142110@r34g2000hsd.googlegroups.com.. .
> .
> .
>
>
>
>
>
> > 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.