Ip-abuse-lookup.sh

software development

#1

I’m trying to run the file “ip-abuse-lookup.sh” as described on: http://wiki.dreamhost.com/Block_IP_Abuse and I’m getting the following when run from my home dir:
./ip-abuse-lookup.sh
#: bad interpreter: No such file or director
(this is what is used in the wiki article) or
.ip-abuse-lookup.sh
-bash: .ip-abuse-lookup.sh: command not found
Can someone tell me what I’m doing wrong here??


#2

You may want to try
sh ./ip-abuse-lookup.sh

$50 off and 3 free domains with code: [color=#CC0000]DH3[/color] Sign Up NOW or More Codes Here


#3

You can also add the following as the first line of your shell script:

More Dreamhost coupons here!


#4

The #!/bin/sh is already on the first line of the script.


#5

I tried running that, but nothing seemed to happen. I went back to try the original commands and I’m still getting the same errors.

Any other thoughts??


#6

if you run “which sh”, what do you see?

$50 off and 3 free domains with code: [color=#CC0000]DH3[/color] Sign Up NOW or More Codes Here


#7

Let’s follow a basic debugging technique - simplify the problem.

Create a file named test.sh in your home directory. Put the following in it:

#!/bin/sh echo hello worldchmod it to be executable - I use chmod u+x test.sh, but feel free to use your favorite permissions.

From your home directory, type

./test.shYou should see the shell script execute and print “hello world” to your console.

Use the [color=#CC0000]3DOM50[/color] promo code for 3 extra lifetime domains and $50 off
More Dreamhost coupons here!


#8

I was able to get the script running using “vim scriptname” and then “Hit i for insert mode, then right-click to paste your clipboard (the install script) contents, then hit Esc, type :wq (that’s ‘colon’, ‘w’, ‘q’), and press Enter to save and exit.”

Not sure why this wouldn’t work with uploading the file and then running it, as I have done this with other scripts and it worked fine. I did get back “/bin/sh” when I ran “which sh”.

Thanks for all of your suggestions!


#9

If that’s the case, then it’s probably some sort of line ending thing. My guess would be that you probably uploaded the script using Windows line endings rather than Unix line endings which left the shell looking for “/bin/sh\r” rather than the appropriate “/bin/sh”.

Whatever happened, it’s good that you got it working the way you needed =)


#10

If that is the case, I’ll suggest OP to use FileZilla to upload your files. It automatically corrects the carriage return characters between windows and unix.
http://www.freerism.com/?page_id=10

$50 off and 3 free domains with code: [color=#CC0000]DH3[/color] Sign Up NOW or More Codes Here


#11

After uploading the file you can simply run:
dos2unix

which will remove the weird end characters and stuff that things like word pad usually add (notepad I don’t think typically adds these).