0
我在Xcode中有以下AppDelegate.applescript。我創建了一個接口,並且腳本中的所有代碼(以及UI)都可以正常工作。但請注意UI底部的服務器版本(下圖鏈接中的圖片)。現在,這是硬編碼。AppleScript + Xcode - 從cli輸出讀取var並插入文本字段
我想讓它變成動態的,讀取httpd -v |grep version
的輸出,可以是類似於Server version: Apache/2.4.18 (Unix)
的輸出。
換句話說,我希望能夠do shell script "/usr/local/bin/httpd -v |grep version"
並在UI中的某種文本單元格(或其他單元格)中顯示結果。如果更容易,我可以提供該項目。提前致謝!
script AppDelegate
#### PROPERTY LIST ####
property parent : class "NSObject"
property startApache : missing value
property restartApache : missing value
property stopApache : missing value
property editConfig : missing value
property editVHosts : missing value
property openDir : missing value
property resetConfig : missing value
#### APACHE CMDs ####
on startApache_(sender)
do shell script "/usr/local/bin/apachectl start" with administrator privileges
end startApache_
on restartApache_(sender)
do shell script "/usr/local/bin/apachectl restart" with administrator privileges
end restartApache_
on stopApache_(sender)
do shell script "/usr/local/bin/apachectl stop" with administrator privileges
end stopApache_
on editConfig_(sender)
do shell script "open -a /Applications/BBEdit.app /usr/local/etc/apache2/2.4/httpd.conf"
end editConfig_
on editVHosts_(sender)
do shell script "open -a /Applications/BBEdit.app /usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf"
end editVHosts_
on openDir_(sender)
do shell script "open /usr/local/var/www/htdocs/"
end openDir_
on resetConfig_(sender)
display dialog "Are you sure you want to reset the httpd.conf to it's default settings?\n\n This cannot be undone!" with icon stop with title "Reset Configuration File"
do shell script "/usr/sbin/apachectl stop" with administrator privileges
do shell script "cp /usr/local/etc/apache2/2.4/httpd.conf.default /usr/local/etc/apache2/2.4/httpd.conf ; cp /usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf.default /usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf" with administrator privileges
end resetConfig_
on applicationWillFinishLaunching_(aNotification)
end applicationWillFinishLaunching_
on applicationShouldTerminateAfterLastWindowClosed_(sender)
return true
end applicationShouldTerminateAfterLastWindowClosed_
on applicationShouldTerminate_(sender)
return current application's NSTerminateNow
end applicationShouldTerminate_
end script
分配結果的'做外殼script'線給一個變量,文本字段連接到該屬性腳本並將其'stringValue'設置爲變量。 – vadian
我不知道我在做什麼錯。甚至沒有:將我的Outlet設置爲「這是一些文本」正在工作。 –
設置httpdVersion的stringValue()爲「這是一些文本」\也不起作用 –