Sponsored Content
Top Forums Shell Programming and Scripting help with bourne shell script Post 302444782 by closedown on Thursday 12th of August 2010 07:23:07 PM
Old 08-12-2010
help with bourne shell script

Attempting to write a script to eventually notify me via email for when there is packetloss across the backbone. I am looking for values greater than 0% in the mtr field.

Code:
#!/bin/sh
target=www.google.com
date +"%D"_"%T" >> /home/rich/mtr.log
echo "----------------------------------------" >> /home/rich/mtr.log
mtr -report -c 5 $target >> /home/rich/mtr.log
mtrlog=`cat /home/rich/mtr.log | awk '/%/ { print $2 }'`
zeroloss=0%
if [ "$mtrlog" = "$zeroloss" ] ; then
        echo "No packetloss"
fi

With what I have above, it's echoing more than one 0% for the mtr field ( obiously) and comparing it to the zeroloss of 0% which results in it not echoing no packetloss. Do I need a for loop in there for each line?

Example when stripping script to just variables it comes up with:
Code:
mtrlog 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0% 0%

zeroloss 0%


Last edited by Franklin52; 08-13-2010 at 05:10 AM.. Reason: Please use code tags.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Bourne shell script need help please ?

i have this assignment.. and i mad this script but there is something wrong with it.. if anyone can tell me.. watz going on... i would appreciate it.. tHnX in advance.. count=1 val=$2 op=$1 ans=0 if then if then while do ... (7 Replies)
Discussion started by: dezithug
7 Replies

2. Shell Programming and Scripting

bourne shell script

Hi all, Can somebody answer the following query Thanks, Srinivas A shell program that takes one or any number of file directory names as input; sorts the directories given as parameters jointly in the ascending or decending order of choice For EX : dips abc etc desc will sort the files... (2 Replies)
Discussion started by: psrinivas
2 Replies

3. UNIX for Dummies Questions & Answers

Bourne Shell Script

Hello, I'm throwing this out there as a novice to the Unix world...I've been working on a project that requires me to ouput (using the echo command) a list of names in a single column format, but the problem is the input is in row format followed by a blank space...If anyone could give me a... (2 Replies)
Discussion started by: dmhonor914
2 Replies

4. Shell Programming and Scripting

Trouble using substr function with Bourne shell script

Hi, I'm a newbie to UNIX scripting and I'm having some trouble compiling my script. I'm using the Bourne Shell and cannot seem to use the substr function correctly. I'm trying to extract the last two digits of a year that's stored in a variable based off of a condition. I've searched the... (4 Replies)
Discussion started by: E2004
4 Replies

5. Shell Programming and Scripting

cd from a Bourne Shell Script - Please Help

Dear Bourne Shell Expert, I am trying to change the current working directory from within a Bourne Shell script. Simply enough i thought ! As I am sure you are well aware, Inside the script i echo `pwd` and it seems ok, but the shell spawns another shell to execute this and as such, when my... (10 Replies)
Discussion started by: fawqati
10 Replies

6. Shell Programming and Scripting

Bourne: How to invoke an alias from within a shell script

Bourne: How to invoke an alias from within a shell script If I type in the alias in the command line, it runs If I insert that same alias into my shell script and run the shell script, the alias is not invoked. Help please. (2 Replies)
Discussion started by: techshots
2 Replies

7. Shell Programming and Scripting

Bourne Shell script - log for users loggin on and off

Hello all, I'm new to shell scripting and want to make a script that I can write to log the users logging on and off the a unix system. I have had a good look over the past few days to crack it, I think I am getting close. I want a script that runs an infinite loop to check every 5 seconds... (14 Replies)
Discussion started by: noodlesoup
14 Replies

8. Shell Programming and Scripting

bourne shell script error on line containing declare...

Hi, Get the following error when running a shell script with following statement. Syntax error at line 150 : `(' is not expected 150: declare -a VPO_SEV=(Normal Warning Minor Major Critical) it runs fine using bash, so I guess the script should be using bash but is there a... (1 Reply)
Discussion started by: wilsonee
1 Replies

9. Shell Programming and Scripting

Open a file from within a Bourne shell Script

I am suppose to make a program that cuts the extension off of a file. It uses that .ext to decide which program needs to be used to open the file. This only finds the name of the program from a list of programs I made. My problem is when it has the name of the program it needs to use, how can I... (3 Replies)
Discussion started by: dordrix
3 Replies

10. Homework & Coursework Questions

New user needs help with bourne shell script

This is my question, below the question is the template Write and execute a Bourne shell script called homework that will From within the script, create three background processes: a) (2 points) one that saves a long listing of your hidden files to a file named hiddenlist b) (2 points) ... (4 Replies)
Discussion started by: luislozoya
4 Replies
MTR(8)									mtr								    MTR(8)

NAME
mtr - a network diagnostic tool SYNOPSIS
mtr [-hvrctglspeniu46] [--help] [--version] [--report] [--report-wide] [--report-cycles COUNT] [--curses] [--split] [--raw] [--mpls] [--no- dns] [--gtk] [--address IP.ADD.RE.SS] [--interval SECONDS] [--psize BYTES | -s BYTES] HOSTNAME [PACKETSIZE] DESCRIPTION
mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool. As mtr starts, it investigates the network connection between the host mtr runs on and HOSTNAME. by sending packets with purposly low TTLs. It continues to send packets with low TTL, noting the response time of the intervening routers. This allows mtr to print the response percentage and response times of the internet route to HOSTNAME. A sudden increase in packetloss or response time is often an indication of a bad (or simply overloaded) link. OPTIONS
-h --help Print the summary of command line argument options. -v --version Print the installed version of mtr. -r --report This option puts mtr into report mode. When in this mode, mtr will run for the number of cycles specified by the -c option, and then print statistics and exit. This mode is useful for generating statistics about network quality. Note that each running instance of mtr generates a significant amount of network traffic. Using mtr to measure the quality of your network may result in decreased network performance. -w --report-wide This option puts mtr into wide report mode. When in this mode, mtr will not cut hostnames in the report. -c COUNT --report-cycles COUNT Use this option to set the number of pings sent to determine both the machines on the network and the reliability of those machines. Each cycle lasts one second. -s BYTES --psize BYTES PACKETSIZE These options or a trailing PACKETSIZE on the commandline sets the packet size used for probing. It is in bytes inclusive IP and ICMP headers If set to a negative number, every iteration will use a different, random packetsize upto that number. -t --curses Use this option to force mtr to use the curses based terminal interface (if available). -e --mpls Use this option to tell mtr to display information from ICMP extensions for MPLS (RFC 4950) that are encoded in the response pack- ets. -n --no-dns Use this option to force mtr to display numeric IP numbers and not try to resolve the host names. -o fields order --order fields order Use this option to specify the fields and their order when loading mtr. Example: -o "LSD NBAW" -g --gtk Use this option to force mtr to use the GTK+ based X11 window interface (if available). GTK+ must have been available on the system when mtr was built for this to work. See the GTK+ web page at http://www.gimp.org/gtk/ for more information about GTK+. -p --split Use this option to set mtr to spit out a format that is suitable for a split-user interface. -l --raw Use this option to tell mtr to use the raw output format. This format is better suited for archival of the measurement results. It could be parsed to be presented into any of the other display methods. -a IP.ADD.RE.SS --address IP.ADD.RE.SS Use this option to bind outgoing packets' socket to specific interface, so that any packet will be sent through this interface. NOTE that this option doesn't apply to DNS requests (which could be and could not be what you want). -i SECONDS --interval SECONDS Use this option to specify the positive number of seconds between ICMP ECHO requests. The default value for this parameter is one second. -u Use UDP datagrams instead of ICMP ECHO. -4 Use IPv4 only. -6 Use IPv6 only. BUGS
Some modern routers give a lower priority to ICMP ECHO packets than to other network traffic. Consequently, the reliability of these routers reported by mtr will be significantly lower than the actual reliability of these routers. CONTACT INFORMATION
For the latest version, see the mtr web page at http://www.bitwizard.nl/mtr/. Subscribe to the mtr mailing list. All mtr related announcements are posted to the mtr mailing list. To subscribe, send email to major- domo@lists.xmission.com with subscribe mtr in the body of the message. To send a message to the mailing list, mail to mtr@lists.xmis- sion.com. Bug reports and feature requests should be sent to the mtr mailing list. SEE ALSO
traceroute(8), ping(8). mtr March 4, 1999 MTR(8)
All times are GMT -4. The time now is 04:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy