I get an issue using a shell script on Ubuntu.
My script :
#!/bin/bash
/usr/local/bin/node ./index.js
exec bash
I have set it as executable with:
sudo chmod +x ./index.sh
Then run it with:
sudo ./index.sh
But get:
sudo: unable to execute ./index.sh: No such file or directory
However, the file is there:
$ ls -la
-rwxr-xr-x 1 root root 54 oct. 4 10:05 index.sh
ls -al
? – Carpette Oct 04 '17 at 08:25ls -la
. And same result with the full path :sudo: unable to execute [FULLPATH]/index.sh: No such file or directory
– tonymx227 Oct 04 '17 at 08:37bash
? Usetype bash
to find it, then update the#!
-line in the script. For this simple script, though, you don't needbash
:#!/bin/sh
would be enough. – Kusalananda Oct 04 '17 at 08:39bash
is here :/bin/bash
. And I get the same message error after replacing#!/bin/bash
to#!/bin/sh
... – tonymx227 Oct 04 '17 at 08:43sudo
aliased to something? – Kusalananda Oct 04 '17 at 08:45sudo $PWD/index.sh
– jlliagre Oct 04 '17 at 08:46sudo
to something. The distribution is Ubuntu. – tonymx227 Oct 04 '17 at 08:47sudo $PWD/index.sh
:sudo: unable to execute /var/www/folder1/folder2/index.sh: No such file or directory
– tonymx227 Oct 04 '17 at 08:49dos2unix
to remove these, ortr -d '\r' <index.sh >index.sh-new
to filter all\r
out. – Kusalananda Oct 04 '17 at 08:52sudo $PWD/index.sh
andsudo ls -l $PWD/index.sh
and alsosudo ls $PWD/index.sh | od -c
. But add them to your question. Copy the output from your terminal exactly as it is and use the formatting tools to format it as code. Also, what happens if you try typingsudo $PWD/index
and then hitting TAB? Also, what is the actual path? Are there any spaces in the names offolder1
orfolder2
? – terdon Oct 04 '17 at 08:54dos2unix
seems to be the solution. It works. – tonymx227 Oct 04 '17 at 09:05