foreach中的cisco命令不起作用

时间:2016-02-13 18:56:52

标签: php cisco

我正在尝试将一些命令发送到cisco路由器,命令存储到数据库中,当我想执行该命令时,我将其发送到函数。

$command = "configure terminal<br />router bgp 444444<br />address-family ipv4<br />neighbor x.x.x.x prefix-list NAME out<br />end<br />clear ip bgp x.x.x.x soft out";

如果我逐个声明命令,它将起作用:

//execute the command
public function execCommand()
{
    $this->_send('config terminal');
    $this->_readTo($this->_prompt);
    $this->_send('router bgp 444444');
    $this->_readTo($this->_prompt);
    $this->_send('address-family ipv4');
    $this->_readTo($this->_prompt);
    $this->_send('neighbor x.x.x.x prefix-list NAME out');
    $this->_readTo($this->_prompt);
    $this->_send('end');
    $this->_readTo($this->_prompt);
    $this->_send('clear ip bgp x.x.x.x soft out');
    $this->_readTo($this->_prompt);
    return true;

} //execCommand

如果我通过这样的命令不起作用:

//execute the command
public function execCommand($command)
{
    $cmd = explode("<br />",$command);
    foreach($cmd as $row){
        $this->_send($row);
        $this->_readTo($this->_prompt);         
    }
    return true;

} //execCommand

我使用PHP for CIsco class http://www.soucy.org/ 感谢

0 个答案:

没有答案
相关问题