[SOLVED] write variable in a file
by aristosv from LinuxQuestions.org on (#5EJ15)
When I run this script, the file gets created, but the variable is not passed in the file. How can I render this variable so it's created in the file?
Code:#!/bin/bash
botname=freqtrade1
bash -c 'cat > /etc/systemd/system/$botname.service' << 'EOL'
Description=$botname service
After=network.target
[Service]
ExecStart=/bin/bash -c "cd /root/$botname ; source .env/bin/activate ; freqtrade trade --strategy $botname"
Restart=always
StandardError=append:/var/log/$botname.log
[Install]
WantedBy=multi-user.target
EOL


Code:#!/bin/bash
botname=freqtrade1
bash -c 'cat > /etc/systemd/system/$botname.service' << 'EOL'
Description=$botname service
After=network.target
[Service]
ExecStart=/bin/bash -c "cd /root/$botname ; source .env/bin/activate ; freqtrade trade --strategy $botname"
Restart=always
StandardError=append:/var/log/$botname.log
[Install]
WantedBy=multi-user.target
EOL