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 bashto find it, then update the#!-line in the script. For this simple script, though, you don't needbash:#!/bin/shwould be enough. – Kusalananda Oct 04 '17 at 08:39bashis here :/bin/bash. And I get the same message error after replacing#!/bin/bashto#!/bin/sh... – tonymx227 Oct 04 '17 at 08:43sudoaliased to something? – Kusalananda Oct 04 '17 at 08:45sudo $PWD/index.sh– jlliagre Oct 04 '17 at 08:46sudoto 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:49dos2unixto remove these, ortr -d '\r' <index.sh >index.sh-newto filter all\rout. – Kusalananda Oct 04 '17 at 08:52sudo $PWD/index.shandsudo ls -l $PWD/index.shand 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/indexand then hitting TAB? Also, what is the actual path? Are there any spaces in the names offolder1orfolder2? – terdon Oct 04 '17 at 08:54dos2unixseems to be the solution. It works. – tonymx227 Oct 04 '17 at 09:05