Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I use wvdial to connect to the net with with my USB modem. It works correctly, and I am quite happy with it. When I start it in XFCE I have it set to output to a borderless, transparent terminal so the status displays on my desktop, life is good. Everything is great, I just want to tweak it.

I'm hoping to filter the output with a 'grep -v' to remove unsightly non-information. Here is the output from a sample run. The output is consistantly the same, except for IP addresses..

--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Modem initialized.
--> Sending: ATDT#777
--> Waiting for carrier.
ATDT#777
CONNECT
--> Carrier detected.  Waiting for prompt.
~[7f]}#@!}!}!} }9}"}&} } } } }#}%B#}%}%}&3za[02]}'}"}(}"J};~
--> PPP negotiation detected.
--> Starting pppd at Mon Nov 14 11:00:06 2011
--> Warning: Could not modify /etc/ppp/pap-secrets: Permission denied
--> --> PAP (Password Authentication Protocol) may be flaky.
--> Warning: Could not modify /etc/ppp/chap-secrets: Permission denied
--> --> CHAP (Challenge Handshake) may be flaky.
--> Pid of pppd: 17776
--> Using interface ppp0
--> pppd: >[7f]
--> pppd: >[7f]
--> pppd: >[7f]
--> pppd: >[7f]
--> local  IP address 10.81.25.50
--> pppd: >[7f]
--> remote IP address 10.133.28.10
--> pppd: >[7f]
--> primary   DNS address 10.133.20.11
--> pppd: >[7f]
--> secondary DNS address 10.132.20.11
--> pppd: >[7f]
^CCaught signal 2:  Attempting to exit gracefully...
--> Terminating on signal 15
--> pppd: >[7f]
--> Connect time 0.2 minutes.
--> pppd: >[7f]
--> pppd: >[7f]
--> Disconnecting at Mon Nov 14 11:00:16 2011

Can someone please help me with a command line or script that would filter that output and remove the --> pppd: >[7f] lines, and possibly the pap/chap warnings(they're bogus).

I've tried several things, with pipes and redirection to grep but haven't hit on anything that seems to effect the output. As a note: in the pppd:/[7f] lines it appears the second '>' character could be just about anything(still don't know what pppd is trying to tell me. :)

Thanks!

EDIT: I got it. Simple stuff really, if you're not a knob. I'm a knob..

wvdial 2>&1 | grep -v -i -E "7f]|pap|chap"

the output is on stderr and pipes are for stdout. the 2>&1 redirects so it will pipe properly.

If you've read this far, thanks.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

What I would do is to redirect the output of wvdial to a file, and separately print out “interesting” lines from the file as they appear.

wvdial >wvdial.log 2>&1

Here's one way to filter the file. tail -n +1 -f means to follow the file as it grows (-f), starting with the first line (-n +1). The filter grep -v means to display all but the matching line; -E chooses the “modern” syntax for regular expressions.

tail -n +1 -f wvdial.log |
grep -vE '^--> (pppd: >\[7f\]|Warning)$'

There are several programs that combine the file watch feature of tail -f (which is often called tailing a file) with filtering and coloring capabilities; browse the tail tag on this site and see in particular grep and tail -f? and How to have tail -f show colored output.

share|improve this answer
    
What I've settled on, is redirect to a log file so I capture all output. Then tail -f, piped through grep -v, piped through sed to colorize. I looked at multitail for colorizing, but it looks like it has a learning curve of its own. If I've gotta learn something, at this point it should be regex and the standard tools. :) Thanks for your input! –  BentFX Nov 16 '11 at 6:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.