[英]Bash script that updates self?
I'm writing a utility using Bash scripting and I'd like to include an update feature with it. 我正在使用Bash脚本编写实用程序,我想在其中包含一个更新功能。 The script currently follows Ruby's gem philosophy, eg one command with multiple subcommands:
该脚本当前遵循Ruby的gem原理,例如,一个命令带有多个子命令:
gem help
gem version
gem update
Ideally you would run: 理想情况下,您将运行:
myscript update
But I don't know if this is possible. 但是我不知道这是否可能。
What's the best method of going about this? 最好的方法是什么? I know that writing to the currently running script is a Bad Idea.
我知道写入当前正在运行的脚本是一个坏主意。
Simply invoke wget
to download the new version. 只需调用
wget
即可下载新版本。 After successful download, move it to the current script's location and chmod +x
it. 成功下载后,将其移至当前脚本的位置,然后
chmod +x
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.