![](/img/trans.png)
[英]how do I use Regex in powershell commands with ruby using puppet
[英]How can we apply shell commands by using puppet providers?
我有我的自定義人偶提供者,其屬性確保如下。
....
def create
/* echo 'show system uptime' >> /home/Vinoth/config_vino.txt */
end
def destroy
FileUtils.rm_rf '/home/Vinoth/config_vino.txt'
end
def exists?
File.file? 'config_vino.txt'
end
在清單中ensure = 'present'
。 因此,當文件config_vino.txt
不存在時,我想使用shell命令echo
創建它。 誰能建議如何實現這一目標? 希望我的問題清楚,否則請回來。
我的目標是使用人偶提供程序執行Shell命令。
提前致謝。
在Ruby中,有一些方法可以執行Shell命令。 但是,您實際想要做的就是做到這一點(未經測試):
def create
uptime = `your uptime command`
Puppet::FileSystem.open(filename, nil, 'w') do |file|
file.write("#{uptime}\n")
end
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.