1

I'm trying to execute a shell script on OpenBSD 5.7/amd64. Its a test script used to test a FOSS project. (OpenBSD is one of our targets because it provides an ancient compiler out of the box).

When I attempt to run the script:

$ ./cryptest.sh ksh: ./cryptest.sh: No such file or directory 

However, if I add -x for debugging, the script can magically be found:

$ ksh -x ./cryptest.sh + TEST_RESULTS=cryptest-result.txt + ADD_CXXFLAGS= + uname -s + grep -i -c darwin + IS_DARWIN=0 + uname -s + grep -i -c linux + IS_LINUX=0 + uname -s + grep -i -c cygwin + IS_CYGWIN=0 + uname -s + grep -i -c mingw + IS_MINGW=0 + [ -z ] + [ 0 -ne 0 ] + [ 0 -ne 0 ] + [ 0 -ne 0 ] + [ 0 -ne 0 ] + -x c++ -dM -E -std=c++11 - ... 

I unpacked the ZIP with -aoq. I've checked ownership, permissions etc. I ran it through dos2unix for good measure. I even provided go+rx to try and run it. All the things I know to check (which are few) appear to be OK.

Can anyone explain what's going on?

3
  • 4
    What's the first line of the file?
    – thrig
    CommentedOct 27, 2015 at 22:19
  • 1
    please show output of head cryptest.sh | cat -vt. is the interpreter path in the #! line correct?
    – cas
    CommentedOct 27, 2015 at 23:19
  • Were you able to make any progress with the comments here?
    – Jeff Schaller
    CommentedOct 30, 2015 at 15:35

3 Answers 3

3

Your shell tried and failed to execute the shell specified on the first (shebang) line of cryptest.sh. It is able to find ksh just fine, which is then able to execute your script.

    2

    The path to ksh on the first line of the file doesn't match the path to ksh in your system.

    Edit the file to reflect reality and the script will start as expected.

      0

      It could come from your EOL encoding if you develop on Windows, you must write and save your script with Unix EOL.

      1
      • The question states that the questioner has used dos2unix.
        – JdeBP
        CommentedJan 8, 2020 at 13:06

      You must log in to answer this question.