1

Technically all I'm trying to do is substitute one file with another using a script:

echo "PASSWORD" | sudo -S rm paper_RPG.jar
cp /home/network/PaperAndWaterfallUpdater/paper.jar paper_RPG.jar

First command removes the old paper_RPG.jar, and second command copies the updated paper paper.jar from the update folder, renaming it paper_RPG.jar and leaving it in the same folder where the script is executed.

Yeah, I'm using a password right there because it's really convenient. Suggestions on that are accepted but I already read some and wasn't convinced.

The old file is propperly removed, and the new one is propperly placed (I tried just copying with hopes of overwriting, but old one doesn't overwite and instead both files with the same name remain in the same folder, so I'm also using rm).

However when attempting to execute the jar, I noticed I get an error saying no such file or directory. Listing local files with ls shows the jar has this weird name after having being copied: 'paper_RPG.jar'$'\r' how can I fix this?

1 Answers1

3

Are you creating or editing the script from a Windows (or other non Ubuntu) machine? If so, maybe try running the script through dos2unix and then executing again.

Easy enough to install if not present: sudo apt install dos2unix

Then, just run dos2unix my_script.sh (Make a backup first).

Try running the script again after that.

justus95
  • 351
  • Yes, thank you that fixes it. I'll keep this in mind for futher edits, the script isn't that long so I could just nano it next time. – Mithrandir Jun 20 '20 at 19:49