Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 如何等待wget和tar命令的完成?_Linux_Ssh_Phpseclib - Fatal编程技术网

Linux 如何等待wget和tar命令的完成?

Linux 如何等待wget和tar命令的完成?,linux,ssh,phpseclib,Linux,Ssh,Phpseclib,我有一个类似于下面的代码数组 $ssh->exec('mkdir /root/example'); $ssh->exec('wget -q -P /root http://www.example.com/example.tar.bz2'); $ssh->exec('tar -xjf /root/example.tar.bz2 -C /root/example'); $ssh->exec('rm /root/example.tar.bz2'); 我的问题 下一个命令在wg

我有一个类似于下面的代码数组

$ssh->exec('mkdir /root/example');
$ssh->exec('wget -q -P /root http://www.example.com/example.tar.bz2');
$ssh->exec('tar -xjf /root/example.tar.bz2 -C /root/example');
$ssh->exec('rm /root/example.tar.bz2');
我的问题

下一个命令在wget和tar命令完成之前启动。如何等待wget和tar命令的完成

我试过了

$ssh->exec('mkdir /root/example');
$ssh->exec('wget -q -P /root http://www.example.com/example.tar.bz2');
sleep(10);
$ssh->exec('tar -xjf /root/example.tar.bz2 -C /root/example');
sleep(10);
$ssh->exec('rm /root/example.tar.bz2');
我试过睡眠命令。但不是工作


编辑:我的英语不好。

尝试执行
$ssh->setTimeout(0)。默认情况下,phpseclib在10秒后超时。将超时设置为0将使phpseclib不会超时。PHP可能会,但phpseclib不会。

@MehmetCanErtanLastOfDead-在ssh登录后执行就足够了。每次命令后,超时都会重置为您设置的值。如果将超时设置为30秒,则每个exec()都将有30秒的超时。如果将其设置为0,则没有exec()将超时。