There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Linux and Unix
Tag Cloud
access acer asus bios bsod computer crash driver drivers error ethernet excel freeze gaming google gpu graphics hard drive hardware hdmi internet laptop malware memory monitor motherboard mouse network printer problem ram registry router server slow software sound svchost.exe trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
Bad Intepreter

Reply  
Thread Tools
Kuwaiti Kid's Avatar
Member with 88 posts.
 
Join Date: Feb 2001
25-Feb-2005, 01:11 PM #1
Bad Intepreter
I am new to Red Hat Linux and have been trying to install a Shell Script I found on the internet using vi.

When I try to run the script I get an error message "Bad Intepreter" and don't know what to do to fix the problem. I have copied the Shell Script exactly as it is shown.

I am sure the answer to this is very simple and any help I can get would be very much appreciated
Squashman's Avatar
Trusted Advisor with 18,705 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
25-Feb-2005, 01:13 PM #2
Can you show me the script?
What are the permissions on the file?
Is it a bash script?
What is the path to bash on your system?
Kuwaiti Kid's Avatar
Member with 88 posts.
 
Join Date: Feb 2001
25-Feb-2005, 01:21 PM #3
This is the file I wrote. It is a Firewall and is also meant to link a second computer to the internet through the first:

!/sbin/sh
#firewall.sh
/sbin/iptables -P INPUT DROP
/sbin/iptables -P FORWARD DROP
/sbin/iptables --flush
/sbin/iptables --delete-chain
/sbin/iptables -P FORWARD DROP
/sbin/iptables -P INPUT DROP
/sbin/iptables -A INPUT -i lo --source 127.0.0.1 --destination 127.0.0.1 -j ACCEPT
/sbin/iptables -A INPUT -m state --state "ESTABLISHED,RELATED"-j ACCEPT
/sbin/iptables -A INPUT -p icmp --icmp-type destination-unreachable -j ACCEPT
/sbin/iptables -A INPUT -p icmp --icmp-type time-exceeded -j ACCEPT
/sbin/iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
/sbin/iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables -t nat -A POSTROUTING -o eth0 -J MASQUERADE
echo 1> /proc/sys/net/ipv4/ip_forward
/sbin/iptables -A INPUT -j LOG -m limit --limit 40/minute
/sbin/iptables -A INPUT -J DROP
/sbin/iptables-save > /etc/sysconfig/iptables
echo "$0: Done."
Kuwaiti Kid's Avatar
Member with 88 posts.
 
Join Date: Feb 2001
25-Feb-2005, 01:28 PM #4
This file is located in the sbin directory and to set the permissions I used chmod u+x
Squashman's Avatar
Trusted Advisor with 18,705 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
25-Feb-2005, 02:10 PM #5
Are you sure the path to SH is in /sbin. It is not on my Red Hat 9 box. My default shell is bash so I don't even bother with the first line in my firewall script.

The first line should look like this
#!/bin/sh
Kuwaiti Kid's Avatar
Member with 88 posts.
 
Join Date: Feb 2001
26-Feb-2005, 02:28 AM #6
When I change the first line to #!/bin/sh and I run /sbin/firewall.sh I get the following error:-

sbin/firewall.sh: line 1; !/bin/sh: No such file or directory
iptables v1.2.7a: Unknown arj '-J'
Try 'iptables -h' or 'iptables--help' for more information.
iptbles v1.2.7a: Unknown arg '-J'
short101's Avatar
Member with 108 posts.
 
Join Date: Dec 2003
Location: Oz
26-Feb-2005, 07:38 AM #7
First line of the script should read
#! /bin/sh
not
!/bin/sh
I think you may have just missed the # when you copied it.
Writing iptables rules isnt something that I would take on lightly. You really need to know what you are doing otherwise your leaving your box open to attack. If you dont know what you are doing, I would suggest using a frontend like firestarter or guarddog.

Last edited by short101; 26-Feb-2005 at 07:49 AM..
Squashman's Avatar
Trusted Advisor with 18,705 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
26-Feb-2005, 12:15 PM #8
I don't even think he needs that in the script if the default shell is sh or bash. I do not have it in my Iptables firewall script and it runs just fine.
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 04:34 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.