Home  >  Q&A  >  body text

Linux 执行.sh报错:bad interpreter: No such file or directory

ringa_leeringa_lee2764 days ago512

reply all(5)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 14:49:07

    Add

    to the first line
    #!/bin/sh

    Try it. First make sure /bin/sh exists. From the error message, it seems that the path of the shell program is wrong

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 14:49:07

    1. First make sure the path is correct, cd to the current directory of the file;

    2. Secondly, make sure that the content of the shell file is correct. How to determine the error message with incorrect content: You can correct the correct file content in the system, and then execute it to see what error is reported;

    3. Finally, although you are sure that there is no problem with the file permissions, it is still recommended that you execute it as the root user.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 14:49:07

    This error is not necessarily a problem with the file itself. It may be a problem with a certain line of commands in the script content. Generally, use the
    bash -x filename.sh method to debug.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 14:49:07

    This problem seems to be because you did not write Shebang, that is, the file header lacks #!/bin/bash
    If there is no such line, you can use the file name to check the type of the sh file.

    is text, and after adding this line, it is displayed as a script.

    As for ll, the file name has an asterisk, which means that the file is executable. In fact, the name of the file itself does not have *, but it is included when ll is output.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 14:49:07

    DOS file format?

    reply
    0
  • Cancelreply