Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am quite inexperienced when it comes to Linux and now I am setting up the system. What I want to do is to write a shell script, that will do two things:

  1. Start i2prouter - as I do not want it to run all the time as a daemon as it takes lots of traffic.
  2. Will run new iptables procedures that will set new rules for the internet.

I made a new iptables rules file (called iptables.up.rules)

When I do it from terminal I write the following

i2prouter start
sudo iptables-restore < /etc/iptables.up.rules

But if I just put it in the .sh file and make it executable, it does not seem to work.

share|improve this question
1  
This might be better off on unix.stackexchange.com because it does not appear to be specific to Ubuntu. –  David Edwards Jun 12 '13 at 13:08
1  
This question is relevant to Ubuntu, and the OP chose to post it to Ubuntu, which makes it on-topic. I would not vote to close it as off-topic. –  Flimm Jun 12 '13 at 16:28

2 Answers 2

Shell scripts must start with the following line:

#!/bin/sh

Or /bin/bash, or whatever shell you want to use. So your script file should look like:

#!/bin/sh
i2prouter start
sudo iptables-restore < /etc/iptables.up.rules
share|improve this answer

Do not forget to include shebang ( #!/bin/sh ) and grant execution privilege ( chmod u+x script.sh )

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.