473,408 Members | 2,839 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,408 software developers and data experts.

quiting a program started by perl

1
Hello Guys,

I wrote a script to run a file using a program installed on the system. Now, the whole thing works properly, except I have multiple files that I need the program to run on.
To do his I kept the whole thing in a loop, in which the variable of the loop corresponds to the name of the file.
So by thought, I expected perl to run the loop, open the file using that program and when it's done, it simply goes to the end of the loop and back to the begining and increments, then do it again. Eg.

Expand|Select|Wrap|Line Numbers
  1. for ($x=2; $x >= 0;$x--)
  2. {
  3. for ($y=2; $y >= 0;$y--)
  4. {
  5. system("prog name -f file_$x_$y.ext >tracker_$x$y.log");
  6. }
  7. }
but instead (and rather unexpected), it stops after the first loop, and then when I check its status, I notice the program has just stopped. It's finished what it has to do but it remains within that program, and perl just stays still (I'm guessing waiting for the program to exit).
Now, to solve this I always have to physically press cntrl - C [in the bash (terminal)], and this ends the program (not the script, but the program initiated by the script), and then the loop resumes, only to happen again.

That's why I was hoping I could make perl issue the 'cntrl-c; command and then the loop continues making the whole thing autonomous.
Now, if I make use of the kill, realised it would kill everything [(when I just want to kil the running program (not the script)]. I hope I was explanatory enough.

THanks in advance.
Jan 21 '09 #1
2 1501
Icecrack
174 Expert 100+
if your running Linux, you could try to keep track of the programs PID and issue a Kill command in Linux with the pid for that program.
for e.g
Expand|Select|Wrap|Line Numbers
  1. system("kill pid");
  2.  
As for killing it another way i don't know, i have never tried to run another program from perl.
Jan 21 '09 #2
KevinADC
4,059 Expert 2GB
He has this question on several perl forums where it has numerous replies. Including to use fork() and kill() amongst other recommendations.
Jan 21 '09 #3

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

Similar topics

22
by: edgrsprj | last post by:
PROPOSED EARTHQUAKE FORECASTING COMPUTER PROGRAM DEVELOPMENT EFFORT Posted July 11, 2005 My main earthquake forecasting Web page is: http://www.freewebz.com/eq-forecasting/Data.html ...
80
by: Bibby | last post by:
Hi, I'm interested in getting started in the programming world. I've dabbled in C, C++ and VB6. Which would be the best language to focus my attention to regarding the following considerations: ...
54
by: bnp | last post by:
Hi, I took a test on C. there was an objective question for program output type. following is the program: main() { char ch; int i =2;
21
by: kimimaro | last post by:
Is there anymore methods in exiting your program using pure C language other than return 0?
0
by: Bill | last post by:
Hi all, I have developed a component to wrap MS-Word, and I use this to manage my reports. Itīs a simple components, but itīs very useful...to eliminate this very tiresome declarations like...
3
by: sir.linying | last post by:
My php script is to call perl scipt which makes use of Spreadsheet::ParseExcel module to parse Excel file. I am able to launch php script from command line so that perl script can run and properly...
4
by: kriz4321 | last post by:
I just started to learn CGI as I have some Basic knowledge in perl. Iam Just trying to run a simple Hello world program and i face some problems let me know ifthe procedure I followed is correct. ...
2
by: IvanIV | last post by:
Hi All, I have trouble with embedding a Perl interpreter into a C program. I would like to replace some subroutine in a Perl script without changing this script from my C program. I need...
24
by: Peter Michaux | last post by:
I have a Perl script that I want to run as a set-user-ID program. Many OSes don't allow scripts run as set-user-ID. To make this script portable, it seems I need to write a C wrapper program that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.