Sponsored Content
Top Forums UNIX for Dummies Questions & Answers trying to grep the first few lines of a continuos script, and exit the script anyidea Post 302336578 by drewrockshard on Wednesday 22nd of July 2009 11:46:49 AM
Old 07-22-2009
Quote:
Originally Posted by k00061804
Hi drewrockshard.

What i am trying to do is.

I have to run a script x ( Which loops for ever)

I need to grep a particular line from the output of the script x, Which i expect to be outputted within the first 20 lines, However this scripts stays running forever till i do a ctrl z.

So i am trying to create a script y which will execute script x grep for the expected output and ctrl d from script x. and output the findings from executing script x.

Script y
==============================

Calls script x looks for a pattern and ctrl z from script x.

i need to be able to force exit the script x when i find the pattern

as script x runs continuous


==================================
First of all, I apologize for the lack of "attention to detail". You stated the first 20 lines, not the last 20 lines. In this case, just to correct myself, it would be:

Code:
head -n 20 >> output.txt

or

Code:
head -n 20 > output.txt

Now, on with what you are actually wanting. I find your logic a bit confusing. What I would do, in this case it to take script x and code it to log everything that you need to a log file. I would then have script y run, and run script x, just like you were wanting. After it starts script x, make sure you get the PID of the process and load it into a variable. Then have script y grep the log file of script x and when if finds a match for what you are looking for, have script y kill the pid of script x.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

exit from script

I have a shell script with options, one of which should exit the system (logout), however when I select this option it drops down to shell, is there a command other than exit that will close the session completely ? (1 Reply)
Discussion started by: gefa
1 Replies

2. Shell Programming and Scripting

[Help] PERL Script - grep multiple lines

Hi Gurus, I need some help with the "grep" command or whatever command that you think suitable for me. I'm about to write a perl script to extract a report from the system and submit it to the end users. The input for the script will consist of 3 element. 1) Generation ID 2) Month 3) Year... (6 Replies)
Discussion started by: miskin
6 Replies

3. UNIX for Dummies Questions & Answers

Exit out of the Script Command inside a Script

I'm new to Linux. I have a bash script that invokes an executable. I'd like use the SCRIPT command inside the script and exit out of the script command after it writes to the file. Does this make sense? Below is an example of the contents of my script. #BEGIN SCRIPT script typescript... (6 Replies)
Discussion started by: jmungai
6 Replies

4. UNIX for Dummies Questions & Answers

exit a script

Hi Guys, I have a script which takes reply from user and executes the corresponding scirpt. Below is the script PS3 = 'Enter the options of your choice(x to exit)=>' select useropt in 'List Processess' \ 'List semaphores' do case $REPLY in 1) abc.sh ... (13 Replies)
Discussion started by: vandi
13 Replies

5. Shell Programming and Scripting

How to grep sql error in shell script and exit the script?

I need help in the following script. I want to grep the sql errors insert into the error table and exit the shell script if there is any error, otherwise keep running the scripts. Here is my script #!/bin/csh -f source .orapass set user = $USER set pass = $PASS cd /opt/data/scripts echo... (2 Replies)
Discussion started by: allinshell99
2 Replies

6. Shell Programming and Scripting

shell script: grep multiple lines after pattern match

I have sql file containing lot of queries on different database table. I have to filter specific table queries. Let say i need all queries of test1,test2,test3 along with four lines above it and sql queries can be multi lines or in single line. Input file contains. set INSERT_ID=1; set... (1 Reply)
Discussion started by: mirfan
1 Replies

7. Shell Programming and Scripting

How to get the exit status of a command in nner script to the outer script?

Hi all, I have a shell script inside which i am executing another shell script. In the inner script im executing a command. i want the status of that command in the outer script to perform some validations. How to get its status please help!!1 Im using ksh. (2 Replies)
Discussion started by: Jayaraman
2 Replies

8. Shell Programming and Scripting

How to capture exit code of child script and send it to parent script?

#!/usr/local/bin/bash set -vx /prod/HotelierLinks/palaceLink/bin/PalacefilesWait /prod/HotelierLinks/palaceLink/bin/prodEnvSetup 03212013 & if then echo "fatal error: Palace/HardRock failed!!!!" 1>&2 echo "Palace Failed" | mail -s "Link Failed at Palace/HardRock" -c... (1 Reply)
Discussion started by: aroragaurav.84
1 Replies

9. Shell Programming and Scripting

How to capture the exit code of a shell script in a perl script.?

hi, i want to pop up an alert box using perl script. my requirement is. i am using a html page which calls a perl script. this perl script calls a shell script.. after the shell script ends its execution, i am using exit 0 to terminate the shell script successfully and exit 1 to terminate the... (3 Replies)
Discussion started by: Little
3 Replies

10. AIX

Need to grep two lines from the topas command through a Korn Script

I need to grep two lines from topas command in one of my AIX server. Topas Monitor for host: semas001 EVENTS/QUEUES FILE/TTY Wed Jan 29 10:12:06 2014 Interval: 2 Cswitch 764 Readch 4473.1K Syscall 5166 ... (4 Replies)
Discussion started by: rpm120
4 Replies
IPESCRIPT(1)						      General Commands Manual						      IPESCRIPT(1)

NAME
ipescript - Run an Ipe script (written in Lua) SYNOPSIS
ipescript script { arguments } DESCRIPTION
ipescript runs an Ipe script written in Lua. The Ipe bindings are automatically available in the script. Ipescript looks for the script in any of the script directories. The script argument should not contain the .lua extension. ENVIRONMENT VARIABLES
ipescript respects the following environment variables: IPELATEXDIR the directory where ipetoipe runs Pdflatex. IPESCRIPTS a list of directories where Ipescript will look for scripts. When this variable is not set, Ipe searches first the current directory, then ~/.ipe/scripts, and finally the system-wide Ipe script directory. When this variable is set, it should contain a list of directories, separated by semicolons. A single under- score is replaced by the system-wide Ipe script directory. IPEDEBUG set this to 1 for debugging output from ipescript. AUTHOR
Otfried Cheong REPORTING BUGS
Please report bugs using Ipe bugzilla at http://ipe7.sourceforge.net/bugzilla.html SEE ALSO
Ipe is documented fully in The Ipe Manual, which is available online at http://ipe7.sourceforge.net/manual/manual.html . August 28, 2011 IPESCRIPT(1)
All times are GMT -4. The time now is 12:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy