前段时间没有任何博客写,是因为我去香港逛了一圈。
Submitted by gouki on 2014, January 8, 6:35 PM
前段时间没有任何博客写,是因为我去香港逛了一圈。
Submitted by gouki on 2013, December 24, 9:37 PM
这年头,什么都不可靠。所幸,我还不需要用黄瓜。
Submitted by gouki on 2013, December 17, 5:50 PM
其实这篇文章中的内容在之前我已经有引用过了,就是早先的监控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.
Send yourself an email. If sendmail
is configured on the server, you could do
./long_process && echo "Job done" | sendmail pnj@yourdomain.com
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.
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。
Submitted by gouki on 2013, December 16, 10:45 AM
备份性的文章,所以先不管三七二十一就CP过来,最起码这篇文章是2012年的,短时间内应该还是有效的
今天发现新买的MacBook Pro的一个USB口异常。具体表现是连接到移动硬盘之后,硬盘灯闪亮但是Mac无任何反映。而且,iPhone也无法通过此USB口充电或数据传输。经过Google,找到了下面的步骤来解决:
然后USB口就正常了。事后从Apple的官方文档中找到了这些组合键的作用,并且发现上述步骤其实是两个不同的重置操作。
SHIFT+CTRL+OPTION+POWER十秒钟:重置系统管理控制器(SMC)
注:重置 SMC 时,MagSafe 电源适配器上的 LED 指示灯可能会更改状态或暂时关闭。
在风扇、电源指示灯、系统性能、视频出现某些异常时候,可以通过上述方法进行重置来解决。具体的症状判断和说明可以参考"基于 Intel 的 Mac:重置系统管理控制器(SMC)"。
OPTION+CMD+R+P+POWER:重置NVRAM 或 PRAM
Mac 会将某些设置储存在特殊内存区域中,而且即使关机这些设置也不会丢失(除非存在电池问题)。 在基于 Intel 的 Mac 上,存储位置是称为 NVRAM 的内存;而在基于 PowerPC 的 Mac 上,存储位置则是称为 PRAM 的内存。操作步骤为:
在NVRAM和PRAM中保存着很多硬件的配置,并且不会因为关机而丢失。详细的信息可以参考"重置 Mac 的 PRAM 和 NVRAM","何时要重置 NVRAM 或 PRAM","Mac OS X:PRAM 中存储的是什么"。
当Mac遇到电源和硬件的异常的时候,如果不是外伤则可以考虑进行重置(谨慎,推荐事先咨询天才吧技术人员),如:不能打开、不能从睡眠状态中唤醒、不能给电池充电、不能看到AC适配器,在连接AC适配器后被电击,USB失灵等。另外Power系列和Intel系列还存在着操作上的差异。
但是目前不清楚哪个重置操作解决了USB口失灵的问题;其次不清楚这些重置是否有其他副作用。
-----
话说,这里还有一个英文版:http://www.ruddwire.com/1017/tech/macbook-pro-turns-on-but-screen-stays-black-my-solution/#.Uq5owmRF56A
解决了一个小问题:macbook pro turns on but screen stays black — my solution
The Apple Macbook Pro would turn on, but the screen would not. The screen would stay black. I could tell the computer was on because when I hit the “caps lock” key, the green light on the key would turn on and off.
=================================
If that doesn’t work for you, you could try these steps, documented at apple.com:
Holding down Command, Option, P, and R to reset your PRAM and NVRAM
Resetting PowerBook and iBook Power Management Unit (PMU)
Submitted by gouki on 2013, December 6, 2:01 PM
不多说,上代码。有几个要注意的(这段代码是我从我的系统里剥出来的。写了很久了,只是最近有人一直在问,我想,这也不是什么特别的代码,还是开源吧。)