Re: 013 Barak PPTP on Linksys WRT54G wireless router doesnt work?

From: Oron Peled (oron_at_nonexisting.hamakor.org.il)
Date: Sun 09 Jan 2005 - 08:45:25 IST


On Sunday 09 January 2005 01:28, solomon wrote:
> Here's an improved version ...

Few notes (I should have wrote them on your first post, but
didn't have time then):
  - No need for multiple sed commands in your case. sed is
    capable for executing multiple commands on a single line
    using the '-e' flag (RTFM).
  - You seem to forget (or haven't learned) about regular
    expressions. Simply try to chop piece by piece which is tedious.
  - There are many redirections to small files -- not good.
    A lot of garbage to clean or leave. Also raises some
    security concerns as these run as root (race conditions
    and symlink attacks come to mind).
  - Why create a script and run it? Just run the command directly.
  - What splitpea is doing that cannot be done with sed,grep,tr etc?

So let's do it in a saner way (tested only the first significant line,
you can test the rest for syntax errors etc.):

#! /bin/sh

# Get the other side IP
other=`ifconfig | grep P-t-P: | \
       sed -e 's/^.*P-t-P://' -e 's/ .*$//'`
if [ "$other" = "" ]; then
 echo >&2 "Something's wrong -- no P-t-P IP"
 exit 1
fi
if ! route add -net default gw "$other" ppp0; then
 echo >&2 "Failed to add default route"
 exit 1
fi

# ---- cut here -----------

For the "shell challenged" look no further than the 'abs'
(Advanced Bash Scripting) guide at www.tldp.org.

-- 
Oron Peled                             Voice/Fax: +972-4-8228492
oron_at_actcom.co.il                  http://www.actcom.co.il/~oron
ICQ UIN: 16527398
But it does move!
                -- Galileo Galilei
=================================================================
To unsubscribe, send mail to linux-il-request_at_linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request_at_linux.org.il


This archive was generated by hypermail 2.1.7 : Sun 09 Jan 2005 - 09:02:37 IST