Search code examples
linuxsshvisynology

Can't run a script


I tried to create a script in linux, on a Synology server over SSH

so I wrote a file test.sh

#!/bin/bash
echo "this is a test"

I saved the file. after that I did

chmod 755 test.sh

the I did

./test.sh

then i got this error

-ash "./test.sh" is not found

the file was created in

/root

I don't understand


Solution

  • Your shell (ash?) is trying to execute your script and is getting an ENOENT (no such file or directory) error code back. This can refer to the script itself, but in this case it refers to the interpreter named in the #! line.

    That is, /bin/bash does not exist and that's why the script couldn't be started.

    Workaround: Install bash or (if you don't need any bash specific features) change the first line to #!/bin/sh.