我想自动将perlbrew安装到vagrant box中。 我用.sh文件来完成这个。
provision.sh
apt-get update sudo -H -u vagrant bash -c " \curl -kL https://install.perlbrew.pl | bash" sudo -u vagrant bash -c "source ~/perl5/perlbrew/etc/bashrc"ssh进入流浪者后,我期待着
$ which perlbrew将返回
/home/vagrant/perl5/perlbrew/bin/perlbrew但遗憾的是它什么也没有回报。
I want to automate the installation of perlbrew into the vagrant box. I use .sh file to accomplish this.
provision.sh
apt-get update sudo -H -u vagrant bash -c " \curl -kL https://install.perlbrew.pl | bash" sudo -u vagrant bash -c "source ~/perl5/perlbrew/etc/bashrc"After ssh into the vagrant i expect that
$ which perlbrewwill return
/home/vagrant/perl5/perlbrew/bin/perlbrewbut unfortunately it returns nothing.
最满意答案
source ~/perl5/perlbrew/etc/bashrc命令应用的设置无法在另一个bash会话中显示(并且SSH会话执行新的bash进程)。
您需要将命令source ~/perl5/perlbrew/etc/bashrc到其中一个bash“rc”文件中。
对于具有以下命令的单个用户:
echo "source ~/perl5/perlbrew/etc/bashrc" >> ~/.bashrc对于具有以下命令的所有用户:
echo "source ~/perl5/perlbrew/etc/bashrc" >> /etc/bash.bashrc这样每次启动一个新的bash会话时,它都会运行source ~/perl5/perlbrew/etc/bashrc并应用设置。
There is no way the settings applied by your source ~/perl5/perlbrew/etc/bashrc command would be visible in another bash session (and a SSH session executes a new bash process).
You need to add the command source ~/perl5/perlbrew/etc/bashrc to one of the bash "rc" files.
For a single user with the following command:
echo "source ~/perl5/perlbrew/etc/bashrc" >> ~/.bashrcFor all users with the following command:
echo "source ~/perl5/perlbrew/etc/bashrc" >> /etc/bash.bashrcThis way every time a new bash session is started, it will run source ~/perl5/perlbrew/etc/bashrc and apply the settings.
更多推荐
发布评论