将POST值发送到.sh文件并执行shell命令php

我正在尝试为自己设计一个备份管理器。 我能够成功列出所有文件。 现在我想创建一个名为迁移</ strong>的链接,当点击该链接执行Shell命令并使用SCP将文件迁移到另一个服务器时。 我尝试手动运行其他命令,但只有SCP能够成功传输文件。 但是对于SCP,我们没有输入密码的选项。 </ p>

sshpass似乎也不起作用。</ p>

我还尝试了以下代码,创建了text.exe文件并使用expect运行它 还有工作:</ p>

 #!/ usr / bin / expect 
spawn scp file.zip username @ host:destination
set pass“password”
expect {\ n“*密码:*”{发送“$ pass ”; exp_continue}
}
</ code> </ pre>

请为此提供解决方案。</ p>

此外,我想发送文件.zip 使用post作为文件的名称由phpfunction $ file_name定义。 </ p>

如何使用post或任何其他方法向此test.exe文件发送$ file_name? 所以下面这一行看起来像:</ p>

spawn scp file_name.zip username @ host:destination </ p>

谢谢!</ p>
< / DIV>

展开原文

原文

I am trying to design a Backup Manager for myself. I was able to list all the files successfully. Now i want to create a link called Migrate which when clicked executes a Shell commands and migrate the file to another server using SCP. I tried manually running other commands but only SCP was able to transfer the file successfully. But with SCP, we don't have option to enter password.

sshpass also doesn't seems to work.

I also tried the following code by creating text.exe file and running it using expect but thats also dint work:

#!/usr/bin/expect
        spawn scp  file.zip username@host:destination
        set pass "password"
        expect {
        "*password:*" {send "$pass"; exp_continue}
                  }

Please provide a solution for this.

Further, I want to send the file.zip using post as the name of the file is defined by phpfunction $file_name.

How do i send $file_name using post or anyother method to this test.exe file? so that the following line looks like:

spawn scp file_name.zip username@host:destination

Thank you!

drvpvmz16241016
drvpvmz16241016 我的文件名为foo;rm-rf--no-preserve-root/;#。压缩
3 年多之前 回复
dongzou7134
dongzou7134 使用键进行ssh连接。在任何情况下都不要让file.zip可以访问apache,否则你将被黑客攻击。
3 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问