[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: FW: Help! ipmasqadm problem - Help its still not working



On Wed, Feb 14, 2001 at 09:12:09AM -0600, Vince Mulhollon wrote:
> If unquoted, most shells will search for a file with that name
> before giving up and using the parameter as a string.

Are you sure?  That would be very strange if so.  What would it
want to do with the file called "1" if I said:
	echo 1 >something

I'm afraid I think you're a little confused.

> echo "0" > ./1

This puts the character '0' followed by an end of line character
into the file in the current directory called "1".

> cat 1 > /proc/stuff

This reads the contents of the file called "1" and writes it to
the file called "/proc/stuff".  i.e. "0\n" gets written to
"/proc/stuff"

> Not quoting the one will result in the file 1 being copied to
> /proc/stuff, and file 1 contains a zero, resulting in the

Indeed, but that's irrelevant.

> exact opposite of what was intended.

"cat" is not the same as "echo".

The command to turn on IP forwarding is:
	echo 1 >/proc/sys/net/ipv4/ip_forward
not:
	cat 1 >/proc/sys/net/ipv4/ip_forward

The first sends "1\n" to ip_forward, whereas the second sends
the contents of the file called "1" to ip_forward.  It makes no
difference if 1 is quoted or not.

The quotes are used to stop the shell interpreting "shell
meta-characters" as special characters.

e.g. if you want to write a string containing '<' or '>' or '('
or ')' etc., etc. to a file using echo, you must quote it.

$ echo (
bash: syntax error near unexpected token `('

$ echo "("
(

Hope this helps.

-- 
Michael Wood        | Tel: +27 21 762 0276 | http://www.kingsley.co.za/
wood@kingsley.co.za | Fax: +27 21 761 9930 | Kingsley Technologies



Reply to: