Operating System - HP-UX
1834826 Members
3173 Online
110070 Solutions
New Discussion

Editing a commad response to a switch BPX

 
Hunan_1
Frequent Advisor

Editing a commad response to a switch BPX

Hi all, The log I need editing is the command response to a switch BPX.

First I run a script which send commands to a switch BPX, then I catch the response generated redirecting it to a file.

When I read the file in solaris using tail there is no matter(I read at least the last lines), when I use more or other command like cat, almost all the response displayed are just ascci characters.

When I try to read the file in HP-UX is even worst, I can't read the file anyway.

I would be rally pleased If someone could help me.

The command response is in the file attached, the command sent is dspcons.
8 REPLIES 8
A. Clay Stephenson
Acclaimed Contributor

Re: Editing a commad response to a switch BPX

Most of the garbage in the file consists of terminal escape sequences. If you could set and export TERM=unknown before running your command, I suspect that you would see much less garbage in stdout.
If it ain't broke, I can fix that.
Hunan_1
Frequent Advisor

Re: Editing a commad response to a switch BPX

Thanks for your suggestions Clay, but when I use tail to read the file that is being filled when the script is running I can read all the information. I guess I don't need to change the terminal.

I'll try it rigth now anyway.
A. Clay Stephenson
Acclaimed Contributor

Re: Editing a commad response to a switch BPX

Of course you can read it when using a terminal - it understands what all those clear screens and cursor position commands mean. The problem is when you redirect stdout and then try to examine the file it looks like garbage. For that reason, a very simple terminfo may not look as pretty but the garbage when redirected to a file will be reduced by a factor or 100 or so.
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: Editing a commad response to a switch BPX

I suppose that I should try to explain my plan. If you use a very simple terminfo definition like 'unknown' then very, very few terminal sequences are defined so that when your applications makea a clear screen request for example, instead of something like ESC[2C being emitted nothing is sent because the clear command is not defined.
If it ain't broke, I can fix that.
Ron Kinner
Honored Contributor

Re: Editing a commad response to a switch BPX

Your BPX thinks it is talking to a terminal and is sending the usual escape sequences to set up cute menus and in general make it a pretty display. Clay is suggesting that you get the process that is talking to the BPX to tell the BPX that it is using a dumb terminal which does not understand escape sequences thus forcing the BPX to keep its responses to simple text.

See http://enterprise.aacc.edu/~rhs/ansi.html for a simple explanation of the ANSI standard escape sequences.

Another option is to filter the log file to remove all the non ascii characters and Escape sequences.
Dan Salomon at the Univ of Manitoba in Canada has written a program called SCRIPTFIX which runs on UNIX and supposedly does exactly that. If you ask him nicely he might let you use it.
salomon@ccu.umanitoba.ca

Failing that you can try to pipe your log through
col -bx

cat bpx.log | col -bx >pbxlog.txt

and see if that helps.

Ron

Hunan_1
Frequent Advisor

Re: Editing a commad response to a switch BPX

Hi friends, Maybe you haven't noticed that after the fourth line all the additional information seems to be in a single line.

Setting TERM as unknown didn't work.
Ron Kinner
Honored Contributor

Re: Editing a commad response to a switch BPX

Did you try the col idea?

As a proof of concept I tried a little filtering:
A Terminal Escape Sequence is defined as starting with ESC[ and ending with a letter. I loaded your output into Word since I don't have easy access to an HP right now and did a two step replace since I didn't want to bother looking up the ASCII for a [ and it's hard to search on [ with wild cards turned on.

Replace ^027[
with QQQ
Turn on Use Wild Cards
Replace QQQ*[a-zA-Z]
with
one space

That reduces the output to the basic ascii text without formatting. It starts like this:

Last Command: No User

TRUJBPX BPX 8620 No User 9.2.31 Jan. 10 2003 16:11 GMT Last Command: TN Enter User ID: provision Enter Password:

TRUJBPX BPX 8620 provision:1 9.2.31 Jan. 10 2003 16:11 GMT Last Command: TN Next Command: dspcons This dspcons Local Remote Remote Route Channel NodeName Channel State Type Avoid COS O 1.1.0.32 TRUJBPX 3.1.0.32 Ok ubr 1.1.0.33 TRUJBPX 3.1.0.33 Ok ubr 1.1.0.34 TRUJBPX 3.3.0.32 Ok ubr 1.1.0.35 TRUJBPX 3.3.0.33

Which is a bit hard to read but better than we started with. I then did a few obvious insertions of paragraph marks using the Replace feature and the first table now makes sense: See attachment.

It would be fairly simple to write a Perl script which dropped all of the escape sequences except for those ending in H (these are position indicators) and then went through and formatted the document and removed the H sequences one at a time while putting the words in the right places. Do you have Perl on your system or are you willing to install it?

Ron

Hunan_1
Frequent Advisor

Re: Editing a commad response to a switch BPX

Ron, It is ok but just for the first window the BPX shows.

I give an example, the response is like if you were reading a file with more, you need tell the BPX you wanna read the information that follows. But in this case the information on the current window depends of that shown on the last window, although I'm not sure about this.