我编写了一个简单的脚本,以便wget和zenity来取消:
#!/bin/bash
((
wget http://d3qnbzt7ix5jlv.cloudfront.net/ubuntu-12.04-desktop-i386.iso & export PID=$$
wait $PID
export YES=$?
)&) | zenity --progress --pulsate --auto-close
if [ $? -eq 1 ]; then
kill $PID
fi
if [ "$YES" = "0" ]; then
zenity --info
elif [ "$YES" = "1" ]; then
zenity --error
fi杀死没有看到进程$PID。Zenity不显示最终窗口($YES)。为什么?
发布于 2015-10-28 15:04:02
这并不是一个确切的答案,但评论会混淆代码片段:
/usr/bin/userinstall-wget
#!/bin/sh
# a wget wrapper to get these under a separate shell *and* progname
[ -n "$1" -a -n "$2" ] || exit 1
LANG=C \
wget -O "$1" --content-disposition --progress=bar:force:noscroll "$2" 2>&1 \
| stdbuf -i0 -o0 -e0 tr '>' '\n' \
| stdbuf -i0 -o0 -e0 sed -rn 's/^.*\<([0-9]+)%\[.*$/\1/p'# NB: those coughing at this particular killall are welcome with patches
download() {
userinstall-wget "$outfile" "$url" | (
trap 'killall userinstall-wget' HUP
zenity --progress --time-remaining --auto-close --auto-kill \
--text="Wait please..." \
--title="Downloading file"
)
}这些都是作为ALT用户安装包装脚本的一部分放在一起的。
HTH
PS:用旧的wget删除--progress=bar:force:noscroll
https://stackoverflow.com/questions/10378778
复制相似问题