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?

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

|improve this answer|||||
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.

|improve this answer|||||
0

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

|improve this answer|||||
  • The question states that the questioner has used dos2unix. – JdeBP Jan 8 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy