Visit Our UNIX and Linux User Community


printing messages on the screen when background process is going on!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting printing messages on the screen when background process is going on!
# 1  
Old 11-03-2009
printing messages on the screen when background process is going on!

hello all,

In my script i have written some messages which should come in screen while some background process is going on..

Like for example:

if i want to add 2 numbers a and b ...when the addition is going on in the background i should get "ADDING TWO NUMBERS>>PLEASE WAIT " message on the screen for few seconds...

what i did is...

used the below code in my script..but it is not printing anything on the screen. but still i'm getting proper output.

But if the messages comes in the screen then the script will look better so please help me..

Code:
print " *******************************************"
print " *********ADDING TWO NUMBERS*****************"
print " ********* PLEASE WAIT ...........*****************"
print " *******************************************"

# 2  
Old 11-03-2009
Please post the script and state exactly how the script will be run and in what context (command line, command line with nohup ... &, cron etc. ).


Adding two numbers on a modern computer should take nanoseconds. Displaying the result on a terminal takes longer.
# 3  
Old 11-03-2009
Perhaps I don't understand, but If you want the message to appear while the work is being done, why run it in the background? Just display your message, do the work, then clear the screen and continue with your script. You can use the "wait" command to make your script wait until the background work is done before it continues, but it defeats the purpose of running it in the background in the first place.
# 4  
Old 11-03-2009
Yes may be it is taking less time to do the work so the print mesasge which is shown above is appearing in the screen...

So please tell me what I can do to the so that the above print message appears on the screen atleast 2-3 seconds..

and if i have use wait command then tell me where i can use the command? i mean before the above print message or after the print message?

---------- Post updated at 07:20 PM ---------- Previous update was at 07:02 PM ----------

Example for my above scenario,

Code:
num=`cat $REQ2 | grep DateTimeStamp | awk -F":" '{print $2}'`
pgrm=`cat $REQ2 | grep Program | awk -F":" '{print $2}'`
name=cat $REQ2 | grep Name | awk -F":" '{print $2}'`
mail=cat $REQ2 | grep email | awk -F":" '{print $2}'`
clear
    print " *********************************************************"
           print " * Extracting information................................*"
           print " * Make sure that the information provided is correct... *"
           print " * And then close the Request info review to continue... *" 
           print " *********************************************************"
clear
print                                 
   printf " Request Information review "
   print                                  
   print " Number                  : $num"
   print " Program                       : $Pgrm"
   print " Name              : $name"
   print " Email                 : $mail"


I want that print message thing to be appear on the screen for sometime before giving the request info review.. Please help

---------- Post updated at 07:57 PM ---------- Previous update was at 07:20 PM ----------

**************************************************************************************************** ********************************

UPDATE:


Now my problem has been solved.. I have used sleep command to get it done..

MODERATORS PLEASE CLOSE THIS THREAD AS IT IS SOLVED

Thanks for all you guys

Last edited by Franklin52; 11-04-2009 at 04:26 AM.. Reason: Please use code tags!

Previous Thread | Next Thread
Test Your Knowledge in Computers #703
Difficulty: Medium
Cross-Origin Resource Sharing (CORS) is a mechanism that uses additional HTTP headers to tell browsers to give a web application running at one origin, access to selected resources from a different origin.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Make background process interact with fg process

Hi, I have written a menu driven shell script in which as per the choice, I run the another script on background. For eg: 1. get info 2)process info 3)modify info All the operations have different scripts which i schedule in background using &. However I wish to display the error... (0 Replies)
Discussion started by: ashima jain
0 Replies

2. AIX

Use of screen in running background jobs and how to use this

Hello, Please advise use of screen in running jobs in nohup background and how to use this Best regards, Vishal (1 Reply)
Discussion started by: Vishal_dba
1 Replies

3. 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

4. Shell Programming and Scripting

A puzzle with a printing function executing in background

Somebody on a thread in the (french) Mandriva Forum recently suggested a script, designed to provide a tool to display kind of "temporisation widgets" on the console (to be ultimately pasted in other more complex scripts). One version of this script was something like the following, which seems... (6 Replies)
Discussion started by: klease
6 Replies

5. UNIX for Dummies Questions & Answers

Script to start background process and then kill process

What I need to learn is how to use a script that launches background processes, and then kills those processes as needed. The script successfully launches the script. But how do I check to see if the job exists before I kill it? I know my problem is mostly failure to understand parameter... (4 Replies)
Discussion started by: holocene
4 Replies

6. UNIX for Dummies Questions & Answers

Prints to screen when background process finishes

If I run "sleep 10&".. when that background process is done, is there a way for unix to print to screen to let me know? Thanks. (1 Reply)
Discussion started by: jmelai
1 Replies

7. Shell Programming and Scripting

Appending to a file without printing to screen

#!/bin/csh awk 'BEGIN { print "Name Exam1 Exam2 Exam 3 Total Grade" }' grades | tee gradesorted awk '{if ($2+$3+$4<50){grade="F"}else if ($2+$3+$4>49 && $2+$3+$4<65) {grade="D"}else if ($2+$3+$4>64 && $2+$3+$4<80){grade="C"} else if ($2+$3+$4>79... (5 Replies)
Discussion started by: lazypeterson
5 Replies

8. UNIX for Advanced & Expert Users

printing to the screen

HPUX 11.0.X / Korn Shell Hope this makes sense. I have a little function to place things on the screen using the column and row parameters. Question is, how can I be sure of where the current cursor postion is so that if I print something to the upper right hand corner of the screen, I can... (2 Replies)
Discussion started by: google
2 Replies

9. Shell Programming and Scripting

capture the process id when starting a background process

Hello all, How do I start a background process and save the process id to a file on my system. For example %wait 5 & will execute and print the process id. I can't figure out how to get it to a file. I've tried: > filename 0>filename 1>filename. Any assistance is most appreciated. Thanks, Jim... (10 Replies)
Discussion started by: jleavitt
10 Replies

Featured Tech Videos