Sponsored Content
Top Forums Shell Programming and Scripting A shell script to run a script which don't get terminated and send a pattern from the output by mail Post 303014385 by Sambit Sahu on Sunday 11th of March 2018 05:25:56 AM
Old 03-11-2018
Hi Don,

I will explain it in a better way. Linux is the operating system and using bash shell.

So the requirement is as below:

We have a script called testit_tas.sh to test the servers which don't get terminated and we pass CTRL+C to kill it everytime. Below is the content of the script:

Code:
!#/bin/bash

./ctftestdump 10.240.56.1 8100 querytas.txt

So when we run this script (./testit_tas.sh) we get this below output on the terminal and it don't get completed. So we kill it manually
Code:
[sasahu@cts-pro-mgmt-srv1 idc_test_tool]$ ./testit_tas.sh
./testit_tas.sh: line 1: !#/bin/bash: No such file or directory
Level Zero : trying to connect/close host 10.240.56.1 at port 8100...
in connect
out connect
Send:[5022=LoginUser|5028=red3|5029=red3|5026=1]
Send:[5022=QueryTas|4=564|5=EA|5045=1|5026=1003]
Send:[5022=QueryTas|4=193|5=E:CUSAN.E|5045=1|5026=1004]
Send:[5022=QueryTas|4=558|5=E|5045=1|5026=1005]
Send:[5022=QueryTas|4=627|5=E:VOD|5045=1|5026=1006]
Send:[5022=QueryTas|4=824|5=E:AASB-ME|5045=1|5026=1007]
Send:[5022=QueryTas|4=205|5=E:SHFIN|5045=1|5026=1008]
Send:[5022=QueryTas|4=216|5=E:2INVE|5045=1|5026=1009]
Send:[5022=QueryTas|4=257|5=E:AT00000FACC2-EUR|5045=1|5026=1010]
Send:[5022=QueryTas|4=873|5=E:AHAN|5045=1|5026=1011]
5026=1|5001=0<ETX>
5022=QueryTas|4=205|5=E:SHFIN|5045=1|5026=1008|5001=-46<ETX>
5022=QueryTas|4=824|5=E:AASB-ME|5045=1|5026=1007|5001=-46<ETX>
5022=QueryTas|4=216|5=E:2INVE|5045=1|5026=1009|5001=-46<ETX>
5001=-203|5026=1003<ETX>
5001=-203|5026=1004<ETX>
5001=-203|5026=1005<ETX>
5001=-203|5026=1010<ETX>
5001=-203|5026=1011<ETX>
^C[sasahu@cts-pro-mgmt-srv1 idc_test_tool]$

So from above output, we need to search the lines for 5001=-46<ETX> and capture these lines. -46 is error. So we want to capture this and alert only these lines over email to specific people.

Once this script is written, we will schedule it in crontab which will run 3 times to do this check.

Also, I know that to abort the script we can find the process id and kill it but am not sure how to include this.

TIA.

Regards,
Sambit
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Send e-mail in Shell script

How to send an error mail from a shell script e.g. mail destination_adr@blabla.int "Message : here an error message " thanks, Ann. (1 Reply)
Discussion started by: annelisa
1 Replies

2. Shell Programming and Scripting

shell script to send a mail

Hi, I need a shell script which runs in the backround for all the 24 hours and send a mail to us regarding the output of the prstat command when the load average increase above certain percent. kindly help me on this...... (1 Reply)
Discussion started by: jayaramanit
1 Replies

3. Shell Programming and Scripting

Shell script to send a mail

Hi , I need to prepare a script which will check my database with specific to particluar table. If the row count exceeds a certain limit, i need to send a mail to a set of Recipients. Being new to unix, please guide me to complete this task. Advance thanks, Sekar. (4 Replies)
Discussion started by: Sekar1
4 Replies

4. Shell Programming and Scripting

how to run a script using cron job and send the output as attachment via e-mail using unix

how to run a script using cron job and send the output as attachment via e-mail using unix. please help me. how my cron job entry should be? As of now my cron job entry is to run the script at specific time, 15 03 * * * /path/sample.sh | mail -s "Logs" email_id In the above entry, what... (8 Replies)
Discussion started by: vidhyaS
8 Replies

5. Shell Programming and Scripting

Run sql script and send to mail if not empty?

Thanks again for helping me out. I was wondering if anyone else has encountered this issue. I have a SQL script that produces a list -however we are only interested in that list if the length is not zero Here is the sql file named dailyBalance.sql select * from Balance where... (1 Reply)
Discussion started by: Astrocloud
1 Replies

6. Shell Programming and Scripting

How to write this script:- check output word and send a mail?

Hi Guys, I am not Good at scripting. I need to write a script such that if output of command shows the particular word in output then send mail to abc@compay.com -bash-3.2$ ps -ef | grep bpbkar root 6040 1 0 13:05:19 ? 0:00 bpbkar -r 2678400 -ru root -dt 47395 -to 0... (20 Replies)
Discussion started by: manalisharmabe
20 Replies

7. Shell Programming and Scripting

To send a mail through shell script

I want to send a mail through shell script,If it is possible Please give me a code. mail id : upload.xxx@example.com (8 Replies)
Discussion started by: kannansoft1985
8 Replies

8. Shell Programming and Scripting

Shell script to send mail alert

HI Guys, I am writing one shell script to send the mail alert to some email id's if the file not modified in last 10 mins but its not working, I believe MTIME is null string is wrong . can you please assist me on this. script :- filename="abc.txt" echo "Filename is $filename"... (1 Reply)
Discussion started by: abhigrkist
1 Replies

9. Shell Programming and Scripting

C shell script wont terminated if i don't modify the shebang

Hi all, I'm new to shell script i wrote some shell script for my colleague, everyone is fine,except on user we are using VNC viewer to work and there are some script start with shebang #! /bin/csh there is an user will not terminate after running the script even if a hello world i need... (5 Replies)
Discussion started by: pilistar0222
5 Replies

10. Shell Programming and Scripting

Run a script before and after reboot automatically and send output to two locations.

Hello Team . I am working a health check script ( bash) to run on linux server ( RedHat) and requirements are 1. The o/p of script need to be send to two diff files . I am testing with tee command . But I am not successful yet , any recommendations if that is the right approach ? 2. The same... (2 Replies)
Discussion started by: Varja
2 Replies
SMS::Send::Test(3pm)					User Contributed Perl Documentation				      SMS::Send::Test(3pm)

NAME
SMS::Send::Test - SMS::Send International-Class Testing Driver SYNOPSIS
# Create a testing sender my $send = SMS::Send->new( 'Test' ); # Clear the message trap $send->clear; # Send a message $send->send_sms( text => 'Hi there', to => '+61(4) 1234 5678', ); # Get the message from the trap my @messages = $send->messages; DESCRIPTION
SMS::Send supports two classes of drivers. An international class named in the format "SMS::Send::Foo", which only accept international numbers in "+1 XXX XXXXX" format, and regional-context drivers in the format "SMS::Send::XX::Foo" which will also accept a non-leading-plus number in the format applicable within that region (in the above case, Australia). SMS::Send::Test is the testing driver for the international class of drivers. Except for the name, it is otherwise identical to SMS::Send::AU::Test. Its two roles are firstly to always exist (be installed) and secondly to act as a "trap" for messages. Messages sent via SMS::Send::Test always succeed, and the messages can be recovered for testing after sending. Note that the trap is done on a per-driver-handle basis, and is not shared between multiple driver handles. METHODS
SMS::Send::Test inherits all the methods of the parent SMS::Send::Driver class, and adds the following. messages The "messages" method retrieves as a list all of the messages in the message trap. clear The "clear" method clears the message trap. This should be done before each chunk of test code to ensure you are starting from a known state. Returns true as a convenience. SUPPORT
Bugs should be reported via the CPAN bug tracker at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SMS-Send <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SMS-Send> For other issues, contact the author. AUTHOR
Adam Kennedy <adamk@cpan.org> COPYRIGHT
Copyright 2005 - 2011 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.14.2 2011-11-09 SMS::Send::Test(3pm)
All times are GMT -4. The time now is 05:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy