2011-01-05 98 views
0

我使用OS X 10.6.5並偶爾通過ssh訪問它。以這種方式訪問​​它時,我需要能夠使用screencapture實用程序拍攝屏幕圖像。對抓屏手冊頁說要做到以下幾點,但是這似乎並沒有爲我工作:如何在OS X上使用'screencapture'

SECURITY CONSIDERATIONS 
    To capture screen content while logged in via ssh, you must launch 
    screencapture in the same mach bootstrap hierarchy as loginwindow: 

    PID=pid of loginwindow 
    sudo launchctl bsexec $PID screencapture [options] 

我使用目前的命令是:

sudo launchctl bsexec 53 screencapture foo.png 

結果是沒有PNG被輸出並且命令靜默地返回。你們能幫助我做這項工作嗎?謝謝!

回答

0

也許這個「要點」幫助:https://gist.github.com/323256

#!/usr/bin/env bash 

screenshot="screnshot.png" 
screencapture='/usr/sbin/screencapture -xC' 

if [ `whoami` == 'root' ]; then 
loginpid=`ps -ax | grep [l]oginwindow.app | awk '{print $1}'` 
launchctl bsexec $loginpid $screencapture $screenshot 
else 
$screencapture $screenshot 
fi 
+0

謝謝,但沒有。這是一個能夠反覆重複我正在做的事情的腳本。爲了完整起見,我嘗試了這些-xC參數,但沒有改變結果。 – c0nsumer 2011-01-05 18:51:38

0

嘗試通過ssh登錄到目前在OS X主顯示登錄的用戶名相同。您應該可以直接在ssh會話中運行screencapture