0

I have a script renaming a file due to the configuration. By what it s renaming file on $last - its adding a space, so the program not working correctly. What can be the problem?

Config file https://configmaker.com/my/TintedRawRubberyChafer.txt

Code

#!/bin/bash

while true 
    do 

    wget https://configmaker.com/my/TintedRawRubberyChafer.txt

    source TintedRawRubberyChafer.txt

    if [-e $curr]; then
        echo "Make changes"
        mv claymore.stub.conf $last
        mv $curr claymore.stub.conf
    fi

    rm TintedRawRubberyChafer.txt | echo "removed"

    sleep 60

done

exit 0

The thing is, the output from console is 'claymore.stub.conf' -> 'zcash'$'\r'. But there must not be '\r'

10
  • I'd never heard of configmaker.com before now. I feel ill seeing just how far the terrible idea of "download arbitrary text from the internet and execute it without care" has spread. python and ruby and node.js developers (amongst others) have a LOT to answer for and better not be standing near any walls when the revolution comes. Security First! viva la revolución!
    – cas
    Jul 29 '17 at 5:48
  • @cas Man, that script must be executed on 158 mining farm. Which are based on EthOs. Whose free memory are 50-60 megabytes. And they should work on 100% for making money. Second. They all are in local server. And the last. The guys who created EthOs ARE USING CONFIGMAKER. This is their on web-site. And you can control 158 servers using this. So what would you say? Jul 29 '17 at 7:00
  • I'd say that telling people to download text and execute it is still stupid, irresponsible, and just plain wrong, no matter what the purpose. It teaches and encourages extremely dangerous habits. Provide the damn variables in some easily parsable format that doesn't require execution. json, for example.
    – cas
    Jul 29 '17 at 7:34
  • if you don't understand my point imagine what would happen to your ecoin mining setup if someone hacked that configmaker.com page and added "rm -rf /" to the downloadable "config". or code that looked for your secret keys or coin wallet and mailed them to somewhere.
    – cas
    Jul 29 '17 at 7:37
  • BTW, it's not necessary to execute the text that is downloaded. It's in a fairly parsable format (key=value) so it would be quite easy to sanity-check and parse it and extract the values and assign them to the right variables. and abort if there's anything even remotely suspicious in the file (i.e. it looks different to what you're expecting).
    – cas
    Jul 29 '17 at 7:40
1

Your '\r' comes from https://configmaker.com/my/TintedRawRubberyChafer.txt which has two defects:

  • its lines are CR-LF terminated (change this with tr -d '\r' or with dos2unix, sed, vim, etc)
  • its last line is not LF-terminated

So bash presumes you mean last=$'zcash\r'.

Morevover:

  • unless really necessary, you should quote your variables ("$last" not $last)
  • [-e $curr] should be written [ -e $curr ], or best [ -e "$curr" ] (spaces are important)
  • your | echo does not need a pipe. Just put echo on a separate line.
  • since you do not check for errors, your wget+source+rm could simply be written:

    source <(wget -O- https://configmaker.com/my/TintedRawRubberyChafer.txt)

2
  • I am completely noob in bash programing, so can you explain me how to change it, or where do i need to use tr -d '\r'. Thanks. Jul 28 '17 at 15:11
  • Use your favorite editor and ask it to not terminate lines with CR-LF but just LF. Any serious editor should be able to offer this
    – xhienne
    Jul 28 '17 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.