So, I am trying to automate the creation of the linux arch instance through the python script fabric as follows:
from fabric.api import run, sudo
def server_setup_communityrepo():
run('echo \'echo "[archlinuxfr]" >> /etc/pacman.conf\' | sudo -s')
run('echo \'echo "Server = http://repo.archlinux.fr/$arch" >> /etc/pacman.conf\' | sudo -s')
run('echo \'echo " " >> /etc/pacman.conf\' | sudo -s')
sudo('pacman -Syy yaourt --noconfirm')
The problem arises in the second call run()due to the $ in sign $arch. This fabric function does not work on line 2 because $, followed by a line, is recognized as a configuration variable. But I really want $ arch to be understood as a literal in
echo 'echo "Server = http://repo.archlinux.fr/$arch" >> /etc/pacman.conf' a call in the bash shell.
How can I "escape" from this trick quirk and designate $ arch as the literal that will be written to my pacman.conf file?
source
share