【发布时间】:2019-11-28 11:11:16
【问题描述】:
这是我的批处理文件脚本,我正在通过任务调度程序运行此脚本 通过使用以下脚本,我可以将 invoice_feed 文件夹中的所有文件复制到网络共享测试文件夹(shared_folder),两台服务器都通过 VPN 连接
Echo off
net use \\windows_servername\test_folder shared_folder_password /user:shared_folder_username
xcopy C:\Apache\htdocs\Invoices\invoice_feed \\windows_servername\\test_folder
如果我想将特定文件复制到网络共享文件夹,那么我将手动将该文件添加到上述批处理脚本中,它运行良好。下面是代码
Echo off
net use \\windows_servername\test_folder shared_folder_password /user:shared_folder_username
xcopy C:\Apache\htdocs\Invoices\invoice_feed\file_to_copy.csv \\windows_servername\\test_folder
我可以使用 PHP 运行这个脚本吗?如果是,那么我可以从 URL 传递动态值并传递它来代替下面的特定文件名吗?
xcopy C:\Apache\htdocs\Invoices\invoice_feed\<?php echo $_GET['csv_file_name']?> \\windows_servername\\test_folder
或者有没有其他方法可以代替我的意思是完全使用 php 在批处理文件中执行此操作? 我正在尝试运行如下脚本
$file_name = $_GET['csv_file_name'];
echo exec('net use \\windows_servername\test_folder shared_folder_password /user:shared_folder_username');
echo exec('xcopy C:\Apache\htdocs\Invoices\invoice_feed\$file_name \\windows_servername\\test_folder');
但没有运气。它显示 0 个文件已复制。我哪里做错了?
【问题讨论】:
-
非常不清楚您要问什么。在执行此批处理脚本和 PHP 之间,这里甚至有任何 any 连接吗?您是否以某种方式调用此 via PHP?如果是这样,请显示该部分。
-
我已经更新了我的问题
-
@04FS ,我已经编辑了我的问题并更新了我的 php 脚本。请检查