I’m trying to update Invoice ninja for the first time. I am trying to use the script version 4.7.0. I keep getting “no such command” or “no such file or directory”. So far I have just copied the script to my ninja directory the tried running it with $ ./script_name.sh or $ sudo ./script_name.sh from within the directory I copied the script to. I am obviously doing it wrong.
You have to alter the permissions so the system sees it as an executable file. Easiest way to do that is
sudo chmod 755 <name_of_file>, which will give Read, Write, and Execute permissions to the file’s owner, and Read/Execute to everyone else.
Then just run the script with
sudo <name_of_file>, and it should take care of the rest. Just make sure you have both locate and wget installed first, or it won’t work.
Also, you don’t technically need an extension, as the system will know what to do with it. But sometimes it makes it easier for the user to have an extension.
Also, almost forgot. You’ll have to put the file into a directory listed in your
$PATH variable. For simplicity’s sake, I recommend just going with
And there’s one final caveat. Depending on how you’re getting the file onto your server (i.e. if you’re copying it over after pasting into notepad or such in Windows), you’ll need to check for DOS line breaks. To do this, simply run
cat -v <name_of_file>. If all the lines end with no special characters, you’re fine. If you see
^M at the end of every line, you’ll need to either run the file through dos2unix (
dos2unix <name_of_file>) or the long way of
cat scriptname.sh | tr -d '\r' > scriptname.new
mv scriptname.new scriptname.sh
chmod 775 scriptname.sh
To avoid that issue entirely, you could simply copy all the text, then login to your server via SSH with something like PuTTY, and paste the code directly into a new file inside your preferred Linux text editor (I prefer mcedit, but that’s just me).
Thanks for your help. I downloaded the script from pastebin. Then uploaded directly using the file manager in Webmin. I had been uploading it to my ninja directory and tried to run it as SU. I’ll try your suggestions and post back…
Thanks again Titanfail. Worked like a champ.
Thanks again Titanfail. Worked like a champ. Script I uploaded had Line breaks every line. Funny Windows added them even though I never opened the file. Ended up just pasting into a new file…
It’s apparently a pastebin thing. Even the raw link has the line breaks. Tried copying and pasting the code from a Linux system and not using Windows at all, and the line breaks still got put in. Definitely interesting.
But glad to hear you got it working!