Bash output analysis script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash output analysis script
# 1  
Old 06-06-2013
Bash output analysis script

I want to create a script to analyse each output from a task while it is running and launch a sub-function if a specific error message is found at any point or to continue as normal.

Code:
#!/bin/bash 
read checker <<< $('Running process')
if [ "$checker" == "Error message" ] ; then 
'Sub-function' 
elif "continue as normal"
fi

# 2  
Old 06-06-2013
Does this process run quickly and quit, or does it slowly print a number of lines?

If it's the latter, which I suspect, I'd do this:

Code:
process | while read LINE
do
        case "$LINE" in
        *Error*)
                echo "Something happened"
                ;;
        esac
done

# 3  
Old 06-06-2013
Yeah the latter, normally 1-2 outputs per second. Thanks, I'll try that.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash process output analysis

Looking to create a script to listen to each output from a task while it is running and launch a function if a specific error message is found at any point and if not to continue uninterrupted. #!/bin/bash read checker <<< $(reaver -i mon0 -b 'target bssid' -vv) if ; then function elif... (1 Reply)
Discussion started by: 3therk1ll
1 Replies

2. Shell Programming and Scripting

Need bash script to ping the servers and rename the output file each time the script is ran

HI, I have a file serverlist in that all host names are placed. i have written a small script #./testping #! /bin/bash for i in `cat serverlist` do ping $i >> output.txt done so now it creates a file output.txt till here fine.. now each time i run this script the output file... (4 Replies)
Discussion started by: madhudeva
4 Replies

3. Shell Programming and Scripting

[Solved] Output in bash script not captured in variable

I'm tring to write down a simple script that would execute a command and wait until it returns a specific result. This is what i did: bjobs_out=`bjobs` while ]; do bjobs_out=`bjobs` sleep 6 done It seems to work until the command 'jobs' return the list of jobs in execution, but... (4 Replies)
Discussion started by: lifedj
4 Replies

4. Shell Programming and Scripting

Bash script show Kill system output

Hi we are calling kill -9 $pid command from bash script it gives below output, but we need to hide the output. i tried /dev/null but ni luck. is there any alternate way to schive this. ../kill_scr.sh: line 42: 1891 Killed /tmp/anr_rest_mul_wc.sh Soalris 10. ... (2 Replies)
Discussion started by: sachinbutala
2 Replies

5. Shell Programming and Scripting

Piping output from a command into bash script

Hi all. I am using procmail to deliver an email to a script I am developing. Procmail delivers the email to the script on standard input. I imagine this is the same as piping input from a command into the script. Hence I've been testing my script by running echo 'test' | sms-autosend-backup.sh ... (2 Replies)
Discussion started by: akindo
2 Replies

6. Shell Programming and Scripting

Reading output from terminal back into bash script

How can I get a bash script to wait and read and count $i messages that a running program (drbl clonezilla) sends to the console (terminal) and only then move on to the next line in the script when the count is matched (the next line is the last line of the script and is a reboot)? The script... (0 Replies)
Discussion started by: dp123
0 Replies

7. UNIX for Dummies Questions & Answers

How do i tell my bash shell script to test the output of a command against something

How do i tell my bash shell script to test the output of the command i'm using?? I want this script to look for lines not equal to 1 then let me know.. $ cat blah ; echo ---- ; cat blah.sh 1 fe 1 fi 1 fo 0 fum 1 blahda 1 blah 0 blahh 1 bla 1 bl 1 blahhh ---- #!/bin/bash while... (1 Reply)
Discussion started by: phpfreak
1 Replies

8. Shell Programming and Scripting

Bash script undesired output

hi guys, When for example, I want to get the size of a partition, I have done the following: # result=`fdisk -l | grep /dev/sda1` # echo $result /dev/sda1 1 15000 120487468+ 83 Linux and then I parse this output to get the size. That's just fine. The problem here is that, when I have a... (4 Replies)
Discussion started by: alirezan
4 Replies

9. Shell Programming and Scripting

Why generate "ash and bash" different output for same bash script?

Hi, For my bash script, terminal with bash is generate an OK output and program works right. already, terminal with ash have "line 48: syntax error: Bad substitution" output and program don't work. :confused: (0 Replies)
Discussion started by: s. murat
0 Replies
Login or Register to Ask a Question