首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Zenity没有取消或显示消息,因为它没有看到变量

Zenity没有取消或显示消息,因为它没有看到变量
EN

Stack Overflow用户
提问于 2012-04-30 05:10:08
回答 1查看 1.1K关注 0票数 1

我编写了一个简单的脚本,以便wget和zenity来取消:

代码语言:javascript
复制
#!/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)。为什么?

EN

回答 1

Stack Overflow用户

发布于 2015-10-28 15:04:02

这并不是一个确切的答案,但评论会混淆代码片段:

/usr/bin/userinstall-wget

代码语言:javascript
复制
#!/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'

代码语言:javascript
复制
# 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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10378778

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档