I'm not entirely sure where to ask or how to formulate this question with correct terminology.
I have script here for managing a game (minecraft) server for the user (bukkit). I've cut out some variables and I want to know why this is not working and a possible solution.
#!/bin/bash
# /etc/init.d/bukkit
USERNAME='bukkit'
MCROOT='/home/$USERNAME'
MCPATH='/home/$USERNAME/Server'
BACKUPPATH='/home/$USERNAME/backups'
SCRIPTLOG='/home/$USERNAME/script.log'
LOGPATH='/home/$USERNAME/Server/logs'
(line 50) cd $MCPATH
(I also like to have $MCROOT in the paths followed by it.)
Running the script gives:
/bin/bukkit: line 50: cd: /home/$USERNAME/Server: No such file or directory
-su: line 0: cd: /home//Server: No such file or directory
The point is to have different USERNAME in different files and I thought I'd save time editing all paths be replacing everything with one variable normally in the rest of the code.
So my other file called "ftb" has USERNAME='ftb'
"/bin/bukkit" is a symbolic link to "/etc/init.d/bukkit"
Have a nice day!
/home/$USERNAME/Server
instead of/home/bukkit/Server
. Use double quotes instead.MCPATH=/home/$USERNAME/Server