Click to See Complete Forum and Search --> : Shell Script Problem


groundzero
12-01-2000, 12:05 PM
Look at this shell script for me.

#!/bin/bash
echo "Turning on IP_FWRD and MASQ"
echo 1 /proc/sys/net/ipv4/ip_forward
/sbin/ipchains -P forward DENY
/sbin/ipchains -A forward -s 10.0.0.0/24 -j MASQ
echo "FIN"

OK when i exe this it return the following....

Turning on IP Forwarding and IP Masqing
:No such file or directoryipv4/ip_forwarding
'for -Pchains:invalid policy DENY
Try '/sbin/ipchain -h bla bla bla
FIN

However I can exe each of the commands at a terminal?
What the heck is up with that
BTW im new to Shell scripting
THANX


------------------
Groundzer0......
Please stop me before I format again. (Im a Serial Formater)

Tigger
12-01-2000, 12:15 PM
the line should be :

echo 1 > /proc/sys/net/ipv4/ip_forward

groundzero
12-01-2000, 12:29 PM
I found the problem
I opened the script in vi and found these ^M s at the end of lines....
Damnit thats what i get for writing it in windows....
btw i have the > in the eco 1 line that was a typo when i posted
thanx guys

njcajun
12-01-2000, 12:38 PM
PS - shouldn't the slash be the other way in you IP range line? ie 10.0.0.0\24

???

I'll have to check my script, but I thought it was a backslash.

PS - to get rid of newline chars in vi...
:%s/<ctrl-v><enter>//g

Works like a charm (oh yeah, that means to type %s and a forward slash, and actually hit ctrl-v, and then enter - you'll see the character pop up when you hit enter. The empty space between the slashes before the 'g' means to replace the char with nothing. The 'g' means to do it globally.)
------------------
...meanwhile, I remain...
...The RedHatted Stepchild...

[This message has been edited by njcajun (edited 01 December 2000).]