dongpu5874 2017-01-20 17:24
浏览 214

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

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!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!