流浪汉提供sed的命令返回错误

问题描述 投票:0回答:1

我试图运行shell作为sed的一部分config.vm.provision命令

  config.vm.provision "shell", inline: <<-SHELL
    systemctl stop firewalld
    systemctl disable firewalld
    swapoff -a
    sed -i '/\/swapfile/s/^/#/g' /etc/fstab
  SHELL

基本上我想要做的就是评论的/etc/fstab文件中的交换项。

但是,我得到一个错误:

    master: Running: inline script
    master: sed: -e expression #1, char 18: unterminated `s' command
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

sed命令,当我在包装盒上,但错误出在运行时,我将它作为我的Vagrantfile的一部分运行完全正常。

任何想法,这可能是为什么?

sed vagrant vagrantfile
1个回答
0
投票

你能试一下吗?

$script = <<-SCRIPT
systemctl stop firewalld
systemctl disable firewalld
swapoff -a
sed -i '/\/swapfile/s/^/#/g' /etc/fstab
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.provision "shell", inline: $script
end
© www.soinside.com 2019 - 2024. All rights reserved.