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

Re: Running Scripts



On Mon, Jul 09, 2001 at 04:03:09PM -0500, Ricky Bryce wrote:
> I am new to Linux and have a question for those of you who do scripting.
> I am running Red Hat Linux 7.1...  This machine is on my home network
> connected to the internet.  Also on the network is an NT machine, a 2000
> advanced server machine, and two windows 2000 workstations. 
> 
> The Linux machine is acting as the gateway to get the other machines on
> the internet.  
> 
> In order to make this happen, I am typing the following lines every time
> linux boots.
> 
> /sbin/ipchains -A forward 207.0.0.0/8 -j MASQ
> 
> Then I get a message that I have to type the following line, so I type
> it:
> 
> echo 1 > /proc/sys/net/ipv4/ip_forward
> 
> This works perfectly, but I want to make it into a script that runs at
> startup.  I tried making a manual script with the text editor called
> "myscript" that is stored at /etc/myscript (with permissions)
> 
> All I am putting in the text file are these 2 lines.  When I type
> /etc/myscript at the command prompt, I do not get an error, but it is
> almost as if the script never did execute.  If I reboot and type these 2
> lines manually, the internet forwarding (masquerade) works perfectly.
> 
> I have attempted to look at the how to's but I am obviously doing
> something wrong.  I figured if I could just get myscript to run
> manually, then I would worry about seeing how to add the script to
> execute at login.

1) to make the script run, assuming you are using bash as a shell,
make a text file with 2 special attributes.  First, the *very* first
line in the file should be "#!/bin/bash" without the quotes.  The
"pound bang" notation tells the shell what program to run the
script with.  If you wanted Perl, you'd use "#!/usr/bin/perl", for
example.  Type "which bash" without the quotes to make sure that
bash in in /bin/.  Second, you need to mark the file as executable.
To make it so that anyone can execute it, do "chmod +x filename".
If you only want the file's owner to execute it, do
"chmod u+x filename".  Replace filename with the correct filename,
in either case.  Look up something like "linux file permissions"
using your favorite search engine (which is certainly google) for
a better explanation of chmod's function, or look at "man chmod".

2) I'll let the local redhat users give you directions on making
the script run on boot.  I'm not sure what exact file names they
use. :)

--Danny, nothing better to do than watch luci-discuss today ;)
-
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.