Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Automatically enable and disable a router's DMZ' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically enable and disable a router's DMZ
Authored by: gvaughn on Oct 19, '05 08:42:59AM

This is a powerful technique. I've done something similar to dialup the modem attached to my SMC router. Yeah, it seems weird to share a dialup connection over wireless, but it lets me sit in the easy chair :-)

Not to be critical, but the two calls to grep and the one to sed could all be accomplished within awk. I don't have the book with me, but the general syntax is /matchstring/ {actions} where the matchstring could handle what you're using grep for. There's also a builtin function in awk called, I think, gsub that does the same thing as sed's s/match//.



[ Reply to This | # ]
Thank you
Authored by: Whosawhatsis on Oct 19, '05 12:33:05PM

Thank you. I get so sick of people using grep for things that awk should be doing.

Learn to use awk correctly: http://www.vectorsite.net/tsawk.html

---
I was offered a penny for my thoughts, so I gave my two cents... I got ripped off.



[ Reply to This | # ]
Thank you
Authored by: kps on Oct 19, '05 05:47:42PM
I get so sick of people using awk for things that sed should be doing :-)
ifconfig | sed -n -e '/127.0.0.1/d' -e 's/.*inet \(.*\) netmask.*/\1/p'
(I also get sick of macosxhints eating backslashes.)

[ Reply to This | # ]
Thank you
Authored by: Whosawhatsis on Oct 20, '05 05:06:03PM
To get the same output using awk:
ifconfig | awk '$1 ~ /^inet$/ && $2 !~ /^127.0.0.1$/ {print $2}'
Shorter, and no backslashes to be stripped out :P

---
I was offered a penny for my thoughts, so I gave my two cents... I got ripped off.

[ Reply to This | # ]