I am trying to run a back script that I wrote that I have placed in the /srv directory on my xubuntu machine.
But when I try to run it, it errors with the following...
user@linuxbox:/srv$ sudo ./backup.sh
sudo: unable to execute ./backup.sh: No such file or directory
The contents of my backup.sh script are as follows...
#!/bin/sh
rsync --update -raz --progress ./git '/media/user/New Volume/BACKUP'
EDIT: I did flip the executable bit using chmod.
Here is the permissions...
-rwxr-xr-x 1 root root 81 Mar 18 17:16 /srv/backup.sh
EDIT: Apparently another running instance of nano is editing my file. But I did a restart of the PC, so not sure how that persisted. Could this be the problem? This happens when I try to edit in nano.
File backup.sh is being edited (by root with nano 2.5.3, PID 14039); continue?
When I try to kill that process by the PID, it says "No such process"
ls -l /srv/backup.sh
(just so we can have it right the in the question and confirm the obvious: that the file is there and executable). – terdon Mar 18 '17 at 23:27ls -l /bin/sh
– Jeff Schaller Mar 19 '17 at 01:07head -n 1 backup.sh|od -t x1
and look for0d
– Michael Homer Mar 19 '17 at 04:41./
and with a full path, both with and withoutsudo
, and post the results. Please do not respond in comments; [edit] your question to include all relevant information. (P.S. The fact that nano believes that another running instance of it is editing the file should not make any difference.) – G-Man Says 'Reinstate Monica' Mar 20 '17 at 01:45cat -A backup.sh
. (The first two or three lines of output should be enough to clarify some issues.) – G-Man Says 'Reinstate Monica' Mar 20 '17 at 01:46sudo
doesn't use a shell. – Michael Homer Mar 21 '17 at 00:53sudo
indeed doesn't use a shell. Actually running the script does though. – Satō Katsura Mar 21 '17 at 06:47bash\r
. – Satō Katsura Mar 21 '17 at 06:50foo
with#!/bar/gain
, dochmod +x foo
, and run./foo
, I getbash: ./foo: /bar/gain: bad interpreter
. Frankly, I’m not sure how it does that, inasmuch as I believe that I understand how shebangs work, and bash should just be gettingENOENT
for./foo
, and it shouldn’t even see the/bar/gain
, and yet somehow it does. Sorry, but I don’t feel like runningstrace
on it right now. – G-Man Says 'Reinstate Monica' Mar 21 '17 at 15:44bash
tries to optimize running scripts and parses the shebang line itself. – Satō Katsura Mar 21 '17 at 18:22od
and/orcat -A
. I give up; I’m voting to close. – G-Man Says 'Reinstate Monica' Mar 21 '17 at 18:30