Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is going on here ?

Status
Not open for further replies.

sumncguy

IS-IT--Management
May 22, 2006
118
US
servername:~> file *.reset
10.218.100.4.reset: ascii text
10.218.101.4.reset: ascii text
10.218.102.4.reset: ascii text
10.218.103.4.reset: ascii text
10.218.104.4.reset: ascii text
10.218.105.4.reset: ascii text
10.218.106.4.reset: ascii text
10.218.200.132.reset: ascii text
10.218.200.4.reset: ascii text
10.218.201.132.reset: ascii text
10.218.201.4.reset: ascii text
10.218.202.132.reset: ascii text
10.218.202.4.reset: ascii text
10.218.99.4.reset: ascii text
pdcd20-snmcpe1:~> grep Mod *.reset
Binary file 10.218.100.4.reset matches
Binary file 10.218.101.4.reset matches
Binary file 10.218.102.4.reset matches
Binary file 10.218.103.4.reset matches
Binary file 10.218.104.4.reset matches
Binary file 10.218.105.4.reset matches
Binary file 10.218.106.4.reset matches
Binary file 10.218.200.132.reset matches
Binary file 10.218.200.4.reset matches
Binary file 10.218.201.132.reset matches
Binary file 10.218.201.4.reset matches
Binary file 10.218.202.132.reset matches
Binary file 10.218.202.4.reset matches
Binary file 10.218.99.4.reset matches
servername:~>
 
Can be that you have non ascii characters in the begining off your files.

If you are sure that files are text files you can use:

grep --text Mod *.reset
 
hexdump will help you sleuth that out as well. you can pipe the (potentially) binary output from grep --text through hexdump too, that is, if you want to see what it's carping about.
 

I found that the problem is that the files are being created in "dos mode", you know ^M at the end of every line.

grep -a works ok .. but Im trying to figure out why these files are created this way only occasionally. Especially when they are created with the same script ... just change statements as necessary.

The script contacts a router, logs in and executes a few commands. I experience this ^M thing only occasionally.

#! /usr/bin/ksh
#
DOIT () {
echo "tacacs login name"
sleep 2
echo "password"
echo "en"
sleep 3
echo "password"
sleep 4
#echo "show boot"
echo "sh ver"
sleep 2
#echo "reset"
sleep 3
#echo "y\n"
sleep 2
echo "exit"
}
#
while read x
do
DOIT | telnet $x >> $x.vers 2>&1
done < routerlist
 
sed is your friend

Code:
sed -e 's/\r//'

placed in your pipe (after the stdout/stderr redirection) or run against the resulting file will strip out all the carriage returns, leaving the linefeeds.

Cheers!
 


Maybe I didnt make my description clear enough.

When it comes to the basic issue ...

why are the files being created in dos format all of a sudden when I have been using the identical script for lets say a year and the files were written in Unix format ?
 
solar flares? bit rot??

:)

Really though, it might actually be the other way around, where the reset files were entirely dos mode, and then had some unix mode lines prepended. grep would defenetly complain about that as a binary file.

Any changes made to that script over the past while? New IOS version? It may very well be that a new revision of something in the chain of things has changed something. I guess ultimately, you can either fix this by changing that component back the way it was. Or you can make your program more robust and tolerant of it's input by filtering out carriage returns.
 


Ha bit rot ?

Nope. No changes to the script with the exception of the router statements sent down to the router and the extension of the log created per device.
 
Maybe someone upgraded your routers and den router outputs "dos lines".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top