On Sunday 09 January 2005 08:45, Oron Peled wrote:
> 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):

First of all, thanks for your post. I'm always willing to learn and will 
examine your version of the script. However, I would like to answer a few of 
the questions you raise about my version in self-defense ;-)


>   - 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).
the -e flag is not necessary and in fact, if you look at my first sed line 
you'll see that I do have 3 commands on a single line

>   - You seem to forget (or haven't learned) about regular
>     expressions. Simply try to chop piece by piece which is tedious.
You're right. I do know about regular expressions, but I guess not enough.


>   - There are many redirections to small files -- not good.
>     A lot of garbage to clean or leave. Also raises some
Actually, most of the small files were for debugging (I wanted to see 
intermediate results) and I could have added the last 2 sed commands to the 3 
mentioned earlier. On the other hand, I don't see a problem with cleaning up 
since everything is written to /tmp.

>     security concerns as these run as root (race conditions
>     and symlink attacks come to mind).
True, but there's no sensitive information. Anyone who succeeds in reaching my 
machine already knows the IP address.

>   - Why create a script and run it? Just run the command directly.
OK

>   - What splitpea is doing that cannot be done with sed,grep,tr etc?
I played with sed and grep and didn't succeed. As said earlier, I'll study 
your version as a learning excercise


> So let's do it in a saner way (tested only the first significant line,
> you can test the rest for syntax errors etc.):
I'm not sure I understand what else has to be tested. I ran your script, as 
is, and it worked.


>
> #! /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.

-- 
Shlomo Solomon
http://come.to/shlomo.solomon
Sent by KMail 1.7.1 (KDE 3.2.3) on LINUX Mandrake 10.1



=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to