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: -
my $success = undef;
-
my $cmdline = EBDTools::os_path("${nh_home}/web/aview/modules/svcrsp-ng/saSync.pl");
-
-
$success = Win32::Spawn($^X, "${^X} $cmdline ${optfile}", $pid);
-
if (! $success) {
-
my $lasterr = Win32::GetLastError();
-
return_configerror("Failed to create commit / sync process (${lasterr}): ${^X} ${cmdline}");
-
}
-
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: -
echo helloworld > c:\helloworld.txt
-
Obviously I am just checkign to see that this actually works. Well I've tried everything, I've tried using back ticks (`c:\mypath\hel loworld.bat`), another Win32::Spawn (i.e as follows ) -
my $success = Win32::Spawn('d:\\eHealth60\bin\helloworld.bat', undef, $pid);
-
if (! $success) {
-
my $lasterr = Win32::GetLastError();
-
my $msg = Win32::FormatMessage($lasterr);
-
Log("medium", "helloworld failed to execute. Reason = $msg.", $Log::LOG_CALLER_NAME);
-
}
-
Nothing works. c:\helloworld.t xt 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
3 4098
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
numberwhun 3,509
Recognized Expert Moderator Specialist
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
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 don't manage. I
have tried both:
kill 'QUIT', $pid;
|
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...
-------------------------------------------------------
use Win32::Process;
|
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) Win32::FormatMessage
TIA
|
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 ".
$SourceFilePath." > ".$rootPath.$DestinationPath.".txt");
This works fine.
since I would like to make it parallel and run 4 processes at a time I
wrote this code:
|
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 function will be able to do what I require:
A: Start a windows application
B: While that application is running regularly monitor a log file
C: If the windows application falls over or locks up, then the monitor process will kill the job and close the...
| |
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,
shift(@args),
join(" ", @args),
0,
Win32::Process::NORMAL_PRIORITY_CLASS|Win32::Process::CREATE_NO_WINDOW|Win32::Process::DETACHED_PROCESS,
$installPath) or $retCode = 99;
|
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 some action.
The java call looks like this:
Win32::SetChildShowWindow(0);
Win32::Process::Create(
|
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 unusable when you don't know where exactly program is.
I've looked at fork() way but there's no fork for windows.
My current solution is
|
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 then wish to run inside a Perl script. This then becomes:
Win32::Process::Create($vxsim_process_object,
"C:\\Tornado\\target\\config\\simpc\\vxWorks.exe",
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |