Pastebin Bash Scripts

Before I finish re-inventing the wheel with my own script management site, I am currently using Pastebin which has an issue for Linux users. It outputs scripts with Windows line endings. This means that wget commands will append

%0D
characters to the end of your URLs, causing them to fail. This is not mitigatd by wrapping your URLs in quotes for some reason either.

Example

Running the command below will fail even though it appears to be a perfectly valid script if you go to the source

wget -O - http://pastebin.com/raw.php?i=f89cQkcV | sudo bash

Solution

Add the following section to your commands when you fetch content from pastebin:

tr -d '\r'

So a complete command would look like so:

wget -O - http://pastebin.com/raw.php?i=f89cQkcV | tr -d '\r' | sudo bash

No comments:

Post a Comment