How to process and run a program in the background in perl?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to process and run a program in the background in perl?
# 1  
Old 02-04-2010
How to process and run a program in the background in perl?

Hi,

I have a query about processing and running Perl program at the background.

I have HTML file called Userform.html which accepts input from the user. As soon as input is given the contol goes to get.cgi (get.cgi does some processing and computing tasks).

Actually get .cgi takes more time so what i want to do is split get.cgi into 2 programs.

1) Display a message (i.e. The Total count of hits related to the users search term say for example is 2000) and a message stating that "your results are processing".

2) Call background program (back.pl) and display the results simultaneously results should be displayed along with the background programs while processing. For Example let us consider I have three tasks.

Code:
#Back.pl

#Task 1
$string="Hello world";
print "<br> $string<br>";

#Task 2
$str="display a message";
print "<br>$str<br>";

#Task 3
print "<br> addition of 2 nos <br>";

Back.pl (background program) has the following tasks. I want the results should be displayed as soon as task 1 is completed and when task 2 is completed and when task3 is completed. The program should not wait to display the results after all the 3 tasks are completed. It should display the results as soon as one task is completed( In this case task1 should be first and so on.

The display can be like this:

Code:
task 1 results
Hello world

Task 2 is processing....
Display a message

Task 3 is processing...
Addition od 2 nos.

Can i do like this in perl?

Any suggestions how can i do this in perl?

How to call a program and run at the background process in per?

I just read few posts on internet they mentioned like use system("perl back.pl &") in Perl. Can i use this and get my desired output?

How can i get the above output in perl or there any other methods in perl ?

Regards
Vanitha

Last edited by vanitham; 02-12-2010 at 12:11 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Run interactive program in background and grep it

I need to run an interactive program in the background so I can grep it for specific data to use for some logic in a script. There is no quiet or background mode on the program so I plan to redirect a document with commands in it and then to grep the output. This is almost working, except... (1 Reply)
Discussion started by: doonan_79
1 Replies

2. Shell Programming and Scripting

How to run Background process one after another

Hii Friends, I am using Perl CGI. I am running A SCP Command via Perl CGI in Background. Like system("scp -r machinename:/PathOfFile/ /Path/WhereToCopyIt/ &) This Copy Process takes some times lets say 15 min. Now I want When This copy process gets complete then send me... (5 Replies)
Discussion started by: Navrattan Bansa
5 Replies

3. Shell Programming and Scripting

How to call a background process in perl?

Hi, I want to put the following code as a parallel or background process The program is as below: $n=10; #Count of files to be created. for($j=0;$j<=$n;$j++) { open(FH,">files_$j.txt") || warn "cannot create a file\n"; { print FH "count of file: $j\n"; #Sample data to be written. just... (5 Replies)
Discussion started by: vanitham
5 Replies

4. Shell Programming and Scripting

How to put FTP process as a background process/job in perl?

Hi, I am using net::ftp for transferring files now i am trying in the same Linux server as a result ftp is very fast but if the server is other location (remote) then the file transferred will be time consuming. So i want try putting FTP part as a background process. I am unaware how to do... (5 Replies)
Discussion started by: vanitham
5 Replies

5. Shell Programming and Scripting

Can you run a unix script from a perl program

Hi all i have a unix script reformatter.sh i have a process whereby this script reformats a file before a perl program is used to update it i am having a little problem automating the entire process . is there a way whereby i can call the unix script from the perl program ? (12 Replies)
Discussion started by: dwightja24
12 Replies

6. Programming

Run external program in background

Hi, in my program i need to run an external program in background.I am aware that there are at least 2 alternatives for this: 1)fork+exec 2)system("program &"); I have read several posts about this,and they all tend to suggest to use fork+exec (and that's what i am doing now). I have some... (2 Replies)
Discussion started by: Zipi
2 Replies

7. UNIX for Advanced & Expert Users

make a foreground running process to run background without hang up

I've tried this a long time ago and was successful but could not remember how i did it. Tried ctrl+Z and then used bg % could not figure what i did after to keep it no hangup - not sure if used nohup -p pid, can u plz help me out if this can be done. Any help will be appreciated. (12 Replies)
Discussion started by: pharos467
12 Replies

8. Shell Programming and Scripting

Run shell program in perl

Hello , I want to run some shell scripts in my perl script. I need to read the script's name from a file ( this file includes the name of all the scripts) and run the script one by one.. Please let me know how to go .. Thanks in advance, Radha (5 Replies)
Discussion started by: s123.radha
5 Replies

9. Shell Programming and Scripting

Perl Background Process - Finshed Yet?

I have a perl process I want to run in background in a cgi, but do not want to continue until process finished code looks like this. sub calc(){ do calculations return value } In another Perl program I call above function such as &calc(); I want to continue after process... (4 Replies)
Discussion started by: photon
4 Replies

10. Shell Programming and Scripting

Perl: Run perl script in the current process

I have a question regarding running perl in the current process. I shall demonstrate with an example. Look at this. sh-2.05b$ pwd /tmp sh-2.05b$ cat test.sh #! /bin/sh cd /etc sh-2.05b$ ./test.sh sh-2.05b$ pwd /tmp sh-2.05b$ . ./test.sh sh-2.05b$ pwd /etc sh-2.05b$ So... (10 Replies)
Discussion started by: vino
10 Replies
Login or Register to Ask a Question