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'
source
a file, you are telling it to read and execute the contents in the current shell process - it's the sh equivalent ofinclude
. If that file containsrm -rf /
then the shell will proceed to delete everything that the user running it has permission to delete. It will execute whatever is in that file. – cas Jul 29 '17 at 11:54IFS=$'\n' tinted=( $(tr -d '\r' < TintedRawRubberyChafer.txt | awk -F'=| ' '/^last=\w+ curr=\w+$/ {print $2, $4}' OFS=$'\n') ); last="$tinted[0]"; curr="$tinted[1]"
. Also, always quote your variables whenever you use them. – cas Jul 29 '17 at 12:07last="${tinted[0]}"; curr="${tinted[1]}"
. with the current input, that will setlast=zcash
andcurr=btc
. – cas Jul 29 '17 at 12:14