tail -f in Case not getting back to select choice


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting tail -f in Case not getting back to select choice
# 1  
Old 01-05-2012
Network tail -f in Case not getting back to select choice

Hi all,
Im trying to do multiple things in one script..

firstly ...i am trying to call another script in one script...
secondly i am redirecting the output of second script in one file.
thirdly i am also using tail -f after the calling of 2nd script.
fourthly, all this is implemented in case under do while loop.

the problem is ...i can get to see details of tail -f...but cannot return to choices i have put using the CASE .

a.sh
Code:
while :
do
echo "please enter 1 to see Blah or 2 to see 2nd script or 3 to exit"
read ans
case $ans in 
1)
echo "hello this is the first script"
;;
2)
echo "this will call another script"
cd to the location of second script
./b.sh > b.out
tail -f b.out 
#:wall: this is where the script stops...i dont get back to the choices!!! and i have to press ctrl + c :(

;;
3)
exit
;;
*)
echo "wrong input"
;;
esac
done

b.sh
Code:
echo "hello this is second script"
db2 connect to database user username using password
db2 "select * form abc.abc_xyz  with ur" 
echo "done"

Kindly help me...wherin i can view the execution of the db2 command...as well as get back to the options i have given using case.
# 2  
Old 01-05-2012
well, the -f switch of tail(1) will make it enter an infinite loop. So what exactly are you trying to do with that tail command?
Maybe less(1) would be more appropriate to view the contents of the stored output?
This User Gave Thanks to mirni For This Post:
# 3  
Old 01-05-2012
I want to see the execution of the second script, since it will go on for like 5 mins with lots of log messages and updation success or failed messages.

so after the second script is done executing, it should take me back at that place where in i can again input either 1 , 2 or 3
# 4  
Old 01-05-2012
I see. Why not just let the script spit output into a terminal?
Code:
./b.sh

Or maybe
Code:
./b.sh | less

if you want some control over it as you read.
Or
Code:
./b.sh | tee b.out | less

to copy the output in a log file for later viewing
This User Gave Thanks to mirni For This Post:
# 5  
Old 01-05-2012
This helped a lot...Thanks...now as soon as the second script is done...i press 'q'...and then i can continue with the other choices!...
Thanks again!!
# 6  
Old 01-05-2012
Yeah. Glad to be of help. Not only you can exit gracefully, less(1) provides a way to search for patterns through pressing '/' and specifying a regex, and other cool stuff, so you can scrutinize your output more efficiently Smilie
# 7  
Old 01-05-2012
hey mirni...if you can help...
now when i get a statement like "updation successful" while executing the 2nd script, how do i write a if else statement as follows..
Code:
if ("updation successful" string is in the .out file) then
  do something
else
 something gone wrong

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

SSD Caching, how its done, right choice?

Hello, someone needed VPS with SSD caching, he want to use server for websites hosting. What does that mean, this SSD caching and is it optimal solution for this? Also i listen some SSD dont like too much of writting so how one can recognise certain SSD is made the way that its not destroyed... (1 Reply)
Discussion started by: postcd
1 Replies

2. What is on Your Mind?

Choice of Linux,IT technology magazines

Hi, I just got one "Linux Magazine January 2013" from LPI cert completition like bonus. First of all I would say that first page title "Living With windows 8" for linux magazine looks epic. (http://goo.gl/uWNQ3) And also content on magazine is more advertise pages and not a rich with good... (2 Replies)
Discussion started by: jabalv
2 Replies

3. Shell Programming and Scripting

Joining multiple files tail on tail

I have 250 files that have 16 columns each - all numbered as follows stat.1000, stat.1001, stat.1002, stat.1003....stat.1250. I would like to join all 250 of them together tail by tail as follows. For example stat.1000 a b c d e f stat.1001 g h i j k l So that my output... (2 Replies)
Discussion started by: kayak
2 Replies

4. Shell Programming and Scripting

prevent multiple tail in back ground

Dears i have a scrip run in unix that need to use the tail -f command, as below: DATE=`date '+%m%d%y'` tail -f /var/messages | grep "start" >> /export/logs/start_${DATE}.out but the problem that the tail -f will be stop and working in the background in then end of the day (23:59:59)... (0 Replies)
Discussion started by: thehero
0 Replies

5. Web Development

Web development language choice?

Hello, After a bit of basic advice please. What web development languages are available and what are the advantages of each? If this is too basic a question, can someone please signpost so i may research this. I ask as I have a couple of websites that i need to develop but new to programming... (16 Replies)
Discussion started by: maqsood
16 Replies

6. Shell Programming and Scripting

Doing a tail in a script and then return back and continue script

Hello all, I am trying to do a tail in a script. But when I quit the tail my script quits also. This is not what I want. I am struggling to get this done. #!/bin/bash askFile() { echo -n "Enter file: " read FILE } doTail() { tail -F "${1}" } askFile doTail... (4 Replies)
Discussion started by: markdark
4 Replies

7. Shell Programming and Scripting

How to replace match multi choice?

Dear All.:D How to replace match multi choice match data in 2 file. my log :: All_service.txt 66853676964@1925500@90255000001@0@20/02/2009 16:05:08@18/03/2009 11:04:42@null 66805979212@1925500@90255000001@0@23/08/2010 14:52:00@23/08/2010 14:52:00@11/08/2010 16:31:40... (7 Replies)
Discussion started by: ooilinlove
7 Replies

8. Shell Programming and Scripting

Script needed to select and delete lower case and mixed case records

HELLO ALL, URGENTLY NEEDED A SCRIPT TO SELECT AND DELETE LOWER AND MIXED CASE RECORDS FROM A COLUMN IN A TABLE. FOR EXAMPLE : Table name is EMPLOYEE and the column name is CITY and the CITY column records will be: Newyork washington ... (1 Reply)
Discussion started by: abhilash mn
1 Replies

9. UNIX Desktop Questions & Answers

Window Manager of the ... Choice

Inspired by Window Manager of the Year threads from LinuxQuestions.org Like these: 2002 | 2003 | 2004 | 2005 | 2006 I wonder what WMs are used by UNIX people ... People sometimes select diffrent WMs for (old and slow) laptop and (overpowered) workstation, that is why poll allows multiple... (8 Replies)
Discussion started by: vermaden
8 Replies
Login or Register to Ask a Question