OVH Community, your new community space.

Sed with wild cards


jonlewi5
20-07-2011, 09:32
ahh ok, ill give that a try cheer myatu

Myatu
19-07-2011, 17:11
Wouldn't it be easier to rewrite that shell script? Ie:

Code:
#!/bin/bash

RESPONSE=`echo $'\c]close' | telnet $1 2> /dev/null`

if [ $? == 0 ]
then
	echo "Woohoo! Something found at $1! This is my result:"
	echo $RESPONSE
else
	echo "Aww, nothing at $1 :("
fi
I think a sed would quickly become unreadable...

jonlewi5
18-07-2011, 21:02
Right i have been pulling my hair out all day with this.
I got a text file, its 14,000 lines long.

It was made by a shell script i wrote that telnet'd to a list of 900 cisco routers and dumped the banners into the text file. Thats all i needed to do. The problem is, i now need to be able to go through that text file and say either, yes there is a banner, or no there isnt and put it in a spreadsheet. There is no way in hell im trawling through that file. so iv been trying to use a "find and replace" technique to change each entry, only thing is, every single entry is different due to the IP adderss being logged.

Sample entries of the text file are as such :


HOST: 192.168.5.1
Trying 192.168.5.1...

^C


HOST: 192.168.1.4
Trying 192.168.1.4...

telnet: Unable to connect to remote host: No route to host

One of the main problems is there are maybe 20 different banner variations..
what i was hoping to basicly do, is have sed trawl through the text file, then when it meets a certain entry to change, say


HOST: 192.168.5.1
Trying 192.168.5.1...

^C

to

HOST DOWN
I want it to just change it to a couple of charatcers and keep the data in order so i can just copypasta it into a spreadsheet.

Any suggestions please please please
oh and sorry for the wall of text, and if i havnt made myself clear, please let me know.