Mourning the loss of our friend, WhitPhil.
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 audio black screen blue screen boot bsod connection crash dell desktop driver dvd email error excel excel 2003 firefox hard drive hardware hijackthis internet keyboard laptop malware monitor network networking outlook problem processor ram recovery router safe mode screen slow sound spyware tdlwsp.dll trojan vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
Bad Intepreter

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
Kuwaiti Kid's Avatar
Member with 88 posts.
 
Join Date: Feb 2001
25-Feb-2005, 12: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
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
25-Feb-2005, 12: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, 12: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, 12:28 PM #4
This file is located in the sbin directory and to set the permissions I used chmod u+x
Squashman's Avatar
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
25-Feb-2005, 01: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, 01: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
Senior Member with 108 posts.
 
Join Date: Dec 2003
Location: Oz
26-Feb-2005, 06: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 06:49 AM.
Squashman's Avatar
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
26-Feb-2005, 11:15 AM #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.
Closed Thread Bookmark and Share

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.

Smart Search

Find your solution!



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


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 12:33 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.