2011-08-23 132 views
3

是否有一個命令行參數允許您在沒有用戶提示的情況下安裝PHP梨?我想自動化以下執行:在沒有用戶提示的情況下安裝PHP梨

wget http://pear.php.net/go-pear.phar 
php go-pear.phar 
pear config-set preferred_state beta 
pear channel-discover pear.phpunit.de 
pear channel-discover components.ez.no 
pear channel-discover pear.symfony-project.com 
pear install --alldeps phpunit/PHPUnit 
rm go-pear.phar 

PHP細末pear.phar提示用戶安裝/配置信息。

+0

這可能是一個愚蠢的問題,但你能把這些命令放到shell腳本中嗎? – transistor1

+0

是的,但php go-pear.phar提示你選擇安裝目錄 –

+0

噢,好吧......我以爲我會把它扔出去:) – transistor1

回答

2

原來expect做到了。以下是我結束了:

install-pear.sh

#!/usr/bin/expect 
spawn wget -O /tmp/go-pear.phar http://pear.php.net/go-pear.phar 
expect eof 

spawn php /tmp/go-pear.phar 

expect "1-11, 'all' or Enter to continue:" 
send "\r" 
expect eof 

spawn rm /tmp/go-pear.phar 

install-phpunit.sh

#!/bin/bash 
./install-pear.sh 
pear config-set preferred_state beta 
pear channel-discover pear.phpunit.de 
pear channel-discover components.ez.no 
pear channel-discover pear.symfony-project.com 
pear install --alldeps phpunit/PHPUnit 

運行:

sudo apt-get install expect 
chmod 744 ./install-pear.sh 
chmod 744 ./install-phpunit.sh 
sudo ./install-phpunit.sh 
+0

我提交了一個更新腳本,以考慮等待產生的進程終止,否則期望自行超前並在安裝之前終止或文件已被下載 – Gary

1

go-pear.phar本身不接受經由CLI任何參數,因此不能在沒有用戶交互運行

當執行藥業股份,文件go-pear-phar.php運行時,(當使用像expect輸入工具除外),其反過來開始PEAR/Start/CLI.php。如您所見,getInstallLocations確實會等待活動用戶輸入而無法跳過它。

相關問題