473,394 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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 4068
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,509 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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.