-3

This question already has an answer here:

I have a simple script that terminates some processes and closes ports as below. I am running metasploitable.

fuser script

However, whenever I run this, it gives the below error. (note that on this file everyone has permissions)

error

marked as duplicate by Christopher, techraf, countermode, GAD3R, Rui F Ribeiro Dec 2 '16 at 15:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

to run a script it must be executable chmod +x portblock.sh then to run it you must add ./ in the beginning

./portblock.sh
  • I am not getting the error : -bash: ./portblock.sh /bin/bash^M: bad interpreter: No such file or directory – tony9099 Dec 2 '16 at 14:45
  • 1
    Looks like you have a dos line ending file. The clue is the ^M. You need to re-save the file using Unix line endings. – Dababi Dec 2 '16 at 14:48
0

First of all make sure you have executable permission for your script.

And then,

Run your script using ./portblock.sh or using sh portblock.sh.

If you don't like to run the script with above mentioned way then update your PATH variable to the script directory.

  • I have 777 permissions on it...I am not getting the error : -bash: ./portblock.sh /bin/bash^M: bad interpreter: No such file or directory – tony9099 Dec 2 '16 at 14:45
  • file was edited by windows, you must run dos2unix portblock.sh – Archemar Dec 2 '16 at 14:47
  • @Archemar thanks. But I need to install the program which seems not to be working in Exploitable – tony9099 Dec 2 '16 at 14:49
  • see stackoverflow.com/questions/14372645/… (hint: sed -i s/\r// ) – Archemar Dec 2 '16 at 14:53
  • 1
    Yes, as @Archemar said, You should run dos2unix. Line endings should use LF not CRLF. – Thushi Dec 2 '16 at 15:05

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