手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆

转:How can I trigger a notification from a remote terminal in OS X

首页 > 苹果相关 >

其实这篇文章中的内容在之前我已经有引用过了,就是早先的监控ltc的脚本。当然现在ltc已经堕落了。。

看标题也可以知道我们想做些什么。所以看看老外们是怎么做的好了,原文在:http://superuser.com/questions/645036/how-can-i-trigger-a-notification-from-a-remote-terminal-in-os-x

You have not specified what kind of notification you want nor what OS the remote server is running so I am going to have to make some assumptions here. I will assume you don't really care what type of notification it is as long as you are notified and that the remote server is running some flavor of *nix.

  1. Send yourself an email. If sendmail is configured on the server, you could do

    ./long_process && echo "Job done" | sendmail pnj@yourdomain.com 
  2. ssh back to your local machine (assuming this is possible) and make it talk to you. See here for more cool ways of making OSX beep at you.

    ./long_process && ssh you@local.ip say "Yo! All done" 

    or

    ./long_process && ssh you@local.ip terminal-notifier -message "Job finished!" -title "Info" 

    If you are connecting from a dynamic IP and you have configured your router so that you can ssh to that dynamic IP, you can do this (assuming you are only currently connected from your remote machine):

    ip=$(who | grep $USER | perl -lne 's/\\((.+?)\\)\s*$//; print "$1"' | tail -n 1) &&  ./long_process && ssh you@$ip terminal-notifier -message "Job finished!" -title "Info" 

    You can set up password-less ssh in the normal way. It should not be affected by the dynamic IP. Once you have done so, the code above will work.

  3. Use pushover and send a notification to your Android or iOS device (if you have one)

    ./long_process && pushover.pl "All done"

---EOF--

这里面有很多方便,但其中的一种就是terminal-notifier。

 




本站采用创作共享版权协议, 要求署名、非商业和保持一致. 本站欢迎任何非商业应用的转载, 但须注明出自"易栈网-膘叔", 保留原始链接, 此外还必须标注原文标题和链接.

« 上一篇 | 下一篇 »

发表评论

评论内容 (必填):