472,805 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

Win32::Spawn not executing embedded process

Hi, I'm having a lot of trouble with the Win32::Spawn module in perl. Here is my situation, I have a Win32::Spawn call which looks like this:

Expand|Select|Wrap|Line Numbers
  1. my $success = undef;
  2. my $cmdline = EBDTools::os_path("${nh_home}/web/aview/modules/svcrsp-ng/saSync.pl");
  3.  
  4. $success = Win32::Spawn($^X, "${^X} $cmdline ${optfile}", $pid);
  5. if (! $success) {
  6.     my $lasterr = Win32::GetLastError();
  7.     return_configerror("Failed to create commit / sync process (${lasterr}): ${^X} ${cmdline}");
  8. }
  9.  
Basically what this does is spawn a new process to call perl and execute saSync.pl. Inside saSunc.pl I am trying to run an internal binary called "helloworld.bat" which has the contents:

Expand|Select|Wrap|Line Numbers
  1. echo helloworld > c:\helloworld.txt
  2.  
Obviously I am just checkign to see that this actually works. Well I've tried everything, I've tried using back ticks (`c:\mypath\helloworld.bat`), another Win32::Spawn (i.e as follows )
Expand|Select|Wrap|Line Numbers
  1. my $success = Win32::Spawn('d:\\eHealth60\bin\helloworld.bat', undef, $pid);
  2. if (! $success) {
  3.     my $lasterr = Win32::GetLastError();
  4.     my $msg = Win32::FormatMessage($lasterr);
  5.     Log("medium", "helloworld failed to execute. Reason = $msg.", $Log::LOG_CALLER_NAME);
  6. }
  7.  
Nothing works. c:\helloworld.txt is not getting created which makes me believe that event tough the Win32::Spawn works with executing it is not actually running helloworld.bat. This is driving my BATTY!

Can anyone help me with this? Does anyone have another method for me to try because ultimately what I require is a process spawned by Win32::Spawn to call another batch file / binary on a sytem and either write the output to a file so after the Win32::Spawn I can retrieve the value or if I could call using back tick (' ') I could then receive the value of the batch file / binary back to my executing program.

Any and all help is greatly appreciated. I no nothing else to try :(

Thanks, -Andy
Sep 12 '07 #1
3 4033
Hmm, ok thinking this may be more complex than I thought.

Anyway while digging I discovered the Win32::Process module. According to the doc I read Win32::Spawn is depreciated and Win32::Process is what is suggested to use. However, I don't know if they really do the same type of operation. Basically what I need is my perl .pl application to keep running while I launch a process to run some back ground commit actions. Right now when I use Win32::Process::Create to create my process I don't see it continuing with the regular execution after the create.

I'll still learning this so maybe I don't fully understand it yet but if anyone has any pointers I'd appreciate it.

Thanks, -Andy
Sep 13 '07 #2
numberwhun
3,504 Expert Mod 2GB
Hmm, ok thinking this may be more complex than I thought.

Anyway while digging I discovered the Win32::Process module. According to the doc I read Win32::Spawn is depreciated and Win32::Process is what is suggested to use. However, I don't know if they really do the same type of operation. Basically what I need is my perl .pl application to keep running while I launch a process to run some back ground commit actions. Right now when I use Win32::Process::Create to create my process I don't see it continuing with the regular execution after the create.

I'll still learning this so maybe I don't fully understand it yet but if anyone has any pointers I'd appreciate it.

Thanks, -Andy
Wow, I really wish that I could help you but I haven't a clue when it comes to Win32 coding in Perl. Sorry I cannot help you.

Worst case, if you are unable to get an answer here, I would post this question on perlmonks.org as I have see Win32 type questions asked and answered over there so there has to be someone that could assist you.

Regards,

Jeff
Sep 13 '07 #3
Wow, I really wish that I could help you but I haven't a clue when it comes to Win32 coding in Perl. Sorry I cannot help you.

Worst case, if you are unable to get an answer here, I would post this question on perlmonks.org as I have see Win32 type questions asked and answered over there so there has to be someone that could assist you.

Regards,

Jeff
Thanks Jeff, I think I'm close to getting this because I've found that using the Win32::Process module allows my launched process to run embedded executables ( which is why I'm going away from Win32::Spawn ) but I believe only need to get a handle on the flags passed to the process creation call to make it so that the process executes in it's own memory space outside of the launching process. Once I get this down I think I'll be good to go.

Thanks again for all your help! I'll see what the perlmonks have to say about my question.

Andy
Sep 13 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Carlo Filippini | last post by:
Hi on a XP machine I start a ftp process with: $pid = open (CMD, "ftp -in -w:1024 -s:$file_cmd $server 2>&1 |") or die "Can't execute: $!"; In some occasions I want to kill the process, but I...
1
by: RL | last post by:
Hi all, I am new and am lost with Win32::Process stuff. I want on perl script to start a process, then another perl script to terminate the same process. I can start a process using......
1
by: rob | last post by:
I created some Perl scripts on Win32 platform, and now I want to support the same for Linux. What are the equivalents for: 1) use Win32::Process; 2) use Win32::Process::Info; 3)...
2
by: Paolo | last post by:
There is something I can't understand which is the following. I have a system command which runs a commandline to unzip a file: my $Out = system ( $rootPath."bin/bin/gunzip -dfc "....
17
by: asearle | last post by:
Hallo everyone, After playing around with 'fork' in order to try to get a one process to monitor another, I have changed my tack and switched to Win32::Process. Indeed, it looks like this...
3
by: jbenezech | last post by:
Hi All, I have a perl script which starts a java process using Win32::Process. Here is the code to start the java proces: Win32::Process::Create($ProcessObj, ...
0
by: jbenezech | last post by:
Hi all , I have a perl/java app running under Win32. The application consists of a perl service (Win32::Daemon) and of java classes. The perl service calls every xx hours java classes to perform...
2
by: Dmitry Teslenko | last post by:
Hello! How to write portable (win32, unix) script that launches another program and continues its execution? I've looked at spawn*() but it doesn't look in PATH dirs on windows so it's totally...
1
by: Tension | last post by:
Hi, I am trying to run a Tornado simulator with Perl. The command line in an ordinary Windows command window looks like this: "C:\Tornado\target\config\simpc\vxWorks.exe /r32000000" Which I...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.