Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.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
Php laravel ssh2 exec命令_Php_Laravel_Ssh_Exec - Fatal编程技术网

Php laravel ssh2 exec命令

Php laravel ssh2 exec命令,php,laravel,ssh,exec,Php,Laravel,Ssh,Exec,我正在尝试创建一些基于ssh2的东西,连接到我的vps,然后创建一些文件并使用exec命令运行它们 我已经完成了一个更大的部分,那就是创建一个目录,将文件从一个目录移动到另一个目录,现在我需要这样做 以前创建的cd目录 nohup./samp03srv 但是如何使用php实现这一点呢 这就是我目前得到的 $ssh = new SSH2($request->ip); if (!$ssh->login("root", "password")) {

我正在尝试创建一些基于ssh2的东西,连接到我的vps,然后创建一些文件并使用exec命令运行它们

我已经完成了一个更大的部分,那就是创建一个目录,将文件从一个目录移动到另一个目录,现在我需要这样做

以前创建的cd目录

nohup./samp03srv

但是如何使用php实现这一点呢

这就是我目前得到的

    $ssh = new SSH2($request->ip);

    if (!$ssh->login("root", "password"))
    {
        return back()->withErrors("Authentication failed! Please check your credentials!");
    }

    $randomNum = substr(str_shuffle("0123456789abcdefghijklmnopqrstvwxyz"), 0, 11);

    $src = $request->path;
    $dest = "/home/servers/$randomNum";

    $ssh->exec("cp -r $src $dest");
    $ssh->disconnect();
如果您需要更多信息,请询问