Shell Scripting for Router, Switch & FW deviation


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Shell Scripting for Router, Switch & FW deviation
# 1  
Old 11-12-2012
Question Shell Scripting for Router, Switch & FW deviation

Hi,
I have written a script for finding deviation for router,switch &fw.
It is working fine on linux server.
But when I try on sunos 5.10 OS it showing "grep: illegal option -- A". I have used grep -C and grep -A.

How it will work on sunos?

Help me out please !!

Last edited by GautamSK; 11-12-2012 at 09:51 AM.. Reason: edit
# 2  
Old 11-12-2012
I don't remember off the top of my head, but does /usr/sfw/bin/ggrep have the -A / -B options? It should have, as these are GNU options.
# 3  
Old 11-12-2012
there are multiple threads on these Forums on how to "simulate" GNU's '-A/-B' of 'grep' on a non-GNU systems - use the Search function at the forums.
# 4  
Old 11-20-2012
Code:
cat $file | grep -A 2 "show system uptime" | grep "booted" | cut -c 21-22 >> $tmp_path/rtdt.txt

this grep option not working on sunos

Last edited by Scott; 11-20-2012 at 02:38 PM.. Reason: Use code tags, please.
# 5  
Old 11-20-2012
Why would it if it's not /usr/sfw/bin/ggrep?

You also have a 'useless use of cat' in there, and the second grep could be bundled with the first, and you could replace all of that command into a single awk or sed command.
This User Gave Thanks to Scott For This Post:
# 6  
Old 11-20-2012
What the others are telling you, and you need to do:
Code:
alias ggrep=/usr/sfw/bin/ggrep
ggrep -A 2 "show system uptime"  $file| grep "booted" | cut -c 21-22 >> $tmp_path/rtdt.txt

This User Gave Thanks to jim mcnamara For This Post:
# 7  
Old 11-20-2012
showing "ggrep: command not found" error.
Code:
uname -a
SunOS zhmas1 5.10 Generic_142900-13 sun4u sparc SUNW,SPARC-Enterprise


Last edited by Scott; 11-20-2012 at 03:12 PM.. Reason: Code tags
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to switch user in shell scripting (without root)?

Hi everyone: I need create a script that must switch user and then must execute certain commands, sadly neither my user nor the second user have no privileges for su - , I've tried everything but seems su doesn't accept input redirection, please help me, ... (4 Replies)
Discussion started by: ooilinlove
4 Replies

2. Shell Programming and Scripting

Help me to perform count & group by operation in shell scripting?

Hi All, I want to display the distinct values in the file and for each distinct value how may occurance or there. Test data: test1.dat 20121105 20121105 20121105 20121105 20121106 20121106 20121106 20121105 I need to display the output like Output (2 Replies)
Discussion started by: bbc17484
2 Replies

3. Shell Programming and Scripting

guidance required: feed load search & display in shell scripting

Hi All, I am fairly new to Shell Scripting, however learning fast ;-) I have been asked to do the below basic shell script :confused: There are few feed files we are recieving in the server from multiple locations spread out during the day, rite now we are checking manually each file... (2 Replies)
Discussion started by: sachaan
2 Replies

4. Post Here to Contact Site Administrators and Moderators

kindly reconsider my post in shell & scripting forum

Hi, this is regarding my post "ksh: how to extract strings from each line based on a condition" . Its not a home work or an assigment. I actually work in retail domain. The data I handle is very complex and confidential.So I can't divulge the actual patterns. In order to explain my problem, I have... (1 Reply)
Discussion started by: angie1234
1 Replies

5. Shell Programming and Scripting

AWK script for standard deviation / root mean square deviation

I have a file with say 50 columns, each containing a whole lot of data. Each column contains data from a separate simulation, but each simulation is related to the data in the last (REFERENCE) column $50 I need to calculate the RMS deviation for each data line, i.e. column 1 relative to... (12 Replies)
Discussion started by: chrisjorg
12 Replies

6. Shell Programming and Scripting

How to switch user in shell scripting (without sudo)?

Hi everyone: I have a big trouble, I need create a script that must switch user and then must execute certain commands, sadly neither my user nor the second user have no privileges for sudo, I've tried everything but seems su doesn't accept input redirection, please help me, it's very... (8 Replies)
Discussion started by: edgarvm
8 Replies

7. IP Networking

EeePC & F5D7230-4 router help

I have a desk top PC, DSL modem, HP C5180 All-in-One, F5d7230-4 router and a second desk top PC with a wireless card. These all work together fine. I bought an Asus EeePC with Linux as the operating system. I can take the EeePC to a coffee shop or city library and log onto the net with no problems.... (2 Replies)
Discussion started by: royace@juno.com
2 Replies

8. Shell Programming and Scripting

Sql & Shell scripting book

Hi, I am looking for some books that have examples of both Oracle SQL and Shell script being used together. For example, to insert 500 rows into a table using a script. I already have books that cover Shell scripting or SQL, but as separate subjects. I am looking for books that have both of... (3 Replies)
Discussion started by: handle123
3 Replies

9. UNIX Desktop Questions & Answers

Shell scripting & programming languages

If I want to do high-end 3d animation, what skell scripting languages, and programming languages shoul I learn? If you know any good resources for learning these languages they would be appreciated. (1 Reply)
Discussion started by: aloysius1001
1 Replies
Login or Register to Ask a Question