本文整理汇总了PHP中Net_SFTP::exec方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_SFTP::exec方法的具体用法?PHP Net_SFTP::exec怎么用?PHP Net_SFTP::exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net_SFTP
的用法示例。
在下文中一共展示了Net_SFTP::exec方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCommand
public function getCommand(\Net_SFTP $ssh)
{
$gitCommand = str_replace("\n", '', $ssh->exec('which git'));
if ($gitCommand == '') {
throw new \Exception('the git command wasn\'t found on this server');
}
return $gitCommand;
}
示例2: exec
/**
* @param $command
*
* @return string
*/
public function exec($command)
{
$sftpDir = $this->pwd();
switch ($this->_connType) {
case SftpHelper::TYPE_SFTP:
default:
$execOutput = $this->_connection->exec('cd ' . $sftpDir . ' && ' . $command);
$this->_lastExecExitStatus = $this->_connection->getExitStatus();
break;
case SftpHelper::TYPE_FTP:
// TODO: test ftp_exec on a server which supports it
$execOutput = '';
$res = @ftp_exec($this->_connection, 'cd ' . $sftpDir . ' && ' . $command);
$this->_lastExecExitStatus = $res ? 0 : 1;
break;
}
return $execOutput;
}
示例3: while
<?php
session_start();
include 'header.php';
include 'Net/SFTP.php';
$file = $_GET['file'];
$sftp = new Net_SFTP(SSH_HOST);
if ($sftp->login($_SESSION['id'], $_SESSION['passwd'])) {
$sftp->exec('cd $w/meshslicer/conf/; sed -i "2s/.*/' . $file . '/" config.ini');
$resultFiles = array_map('trimFile', array_filter(explode("\n", $sftp->exec('cd $w/meshslicer/results/; ls'))));
$check = true;
$index = 1;
while ($check) {
if (!in_array($file . '.out.parts.' . $_SESSION['config'][8] . '.' . $index, $resultFiles)) {
$check = false;
} else {
$index++;
}
}
$outputFile = '../results/' . $file . '.out.parts.' . $_SESSION['config'][8] . '.' . $index;
$result = $sftp->exec('cd $w/meshslicer/conf/; module load metis; ./StandAlone > ' . $outputFile);
if ($result == "") {
if (preg_match('#.mesh$#', $file)) {
$_SESSION['fileList'][] = $file . '.out.eparts.' . $_SESSION['config'][8] . '.' . $index;
// INDEX
$_SESSION['fileList'][] = $file . '.out.nparts.' . $_SESSION['config'][8] . '.' . $index;
// INDEX
sort($_SESSION['fileList']);
} elseif (preg_match('#.graph$#', $file)) {
$_SESSION['fileList'][] = $file . '.out.parts.' . $_SESSION['config'][8] . '.' . $index;
// INDEX
示例4: header
<?php
session_start();
include 'header.php';
include 'Net/SFTP.php';
if (isset($_SESSION['login'])) {
$sftp = new Net_SFTP(SSH_HOST);
if (!$sftp->login($_SESSION["id"], $_SESSION["passwd"])) {
header("location:signin.php?error=1");
}
$ls = array_filter(explode("\n", $sftp->exec("cd \$w; ls -d *\\/")));
if (!in_array("meshslicer/", $ls)) {
$sftp->exec("cd \$w; mkdir meshslicer; cd meshslicer; mkdir conf; mkdir results; cd conf; touch config.ini; echo '0 0 0 0 0 0 0 1 2 0\nnone' > config.ini");
$sftp->put('/scratch/' . $_SESSION["id"] . '/meshslicer/conf/StandAlone', 'uploads/StandAlone', NET_SFTP_LOCAL_FILE);
$sftp->exec("cd \$w/meshslicer/conf/; chmod 777 StandAlone");
}
$_SESSION["fileList"] = array_map('trimFile', array_filter(explode("\n", $sftp->exec("cd \$w/meshslicer; find . -maxdepth 1 -not -type d"))));
unset($_SESSION["login"]);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">