By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,182 Members | 1,138 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,182 IT Pros & Developers. It's quick & easy.

Win32::Spawn not executing embedded process

P: 4
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
Share this Question
Share on Google+
3 Replies


P: 4
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
Expert Mod 2.5K+
P: 3,503
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

P: 4
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

Post your reply

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