【问题标题】:Is there a way to configure a terminal to make a noise when it finishes executing a command?有没有办法配置终端在完成执行命令时发出噪音?
【发布时间】:2013-11-30 06:51:40
【问题描述】:

当我等待一个长时间运行的命令完成时,我经常去浏览互联网等。

但我会定期检查我的终端窗口是否已完成执行。这很烦人。

有没有办法让终端在命令完成时发出声音?或者使用其他东西来模拟这种效果?

【问题讨论】:

    标签: bash terminal


    【解决方案1】:

    试试这个,

    sat:~# command || play somefile.wav
    

    或者

    sat:~# command || zenity --info --title "Alert"  --text "Job Completed"
    

    如果您关心命令状态,请使用&& 成功完成命令,使用|| 完成失败。

    【讨论】:

      【解决方案2】:

      我想出了一个适合我的解决方案。

      一些命令; do_stuff_to_notify_me

      我只需要分号!

      我最终编写了一个小型 Python 脚本来向我发送文本。

      在等待其他脚本完成时在草地上嬉戏的脚本:

      import smtplib
      server = smtplib.SMTP( "smtp.gmail.com", 587 )
      server.starttls()
      server.login( '<your_email>', '<your_password>' )
      
      import urllib2
      random_word_url = "http://randomword.setgetgo.com/get.php"
      response = urllib2.urlopen(random_word_url);
      random_word = response.read()
      
      server.sendmail( '<from>', '<your_phone_number>@mms.att.net', 'Finished your script ' + random_word )
      

      【讨论】:

        猜你喜欢
        • 2017-04-10
        • 1970-01-01
        • 1970-01-01
        • 2019-06-15
        • 1970-01-01
        • 2015-04-18
        • 2021-05-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多