Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.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
将基于Unix的PHP脚本转换为Windows的批处理文件_Php_Batch File - Fatal编程技术网

将基于Unix的PHP脚本转换为Windows的批处理文件

将基于Unix的PHP脚本转换为Windows的批处理文件,php,batch-file,Php,Batch File,我想将这个在Unix系统上运行良好的PHP脚本转换为Windows脚本 我不知道如何重写它。有人能帮我吗 以下是脚本: $cmd = 'nohup sudo -u '.$user.' bash -c "cd ' . escapeshellarg($path) . '; VVERBOSE=true QUEUE=' . escapeshellarg($queue) . ' APP_INCLUDE=' . escapeshellarg($bootstrap_path) . ' INTERVAL=' .

我想将这个在Unix系统上运行良好的PHP脚本转换为Windows脚本

我不知道如何重写它。有人能帮我吗

以下是脚本:

$cmd = 'nohup sudo -u '.$user.' bash -c "cd ' .
escapeshellarg($path) . '; VVERBOSE=true QUEUE=' .
escapeshellarg($queue) . ' APP_INCLUDE=' .
escapeshellarg($bootstrap_path) . ' INTERVAL=' .
escapeshellarg($interval) . ' CAKE=' .
escapeshellarg(CAKE) . ' COUNT=' . $count .
' php ./resque.php';
$cmd .= ' > '. escapeshellarg($log_path).' 2>&1" >/dev/null 2>&1 &';

passthru($cmd);

passthru是PHP中的一种方法,请参见

你知道剧本是做什么的吗?也许可以将其反向工程到windows批处理脚本中

从外观上看,该脚本来自*nix系统it:

以另一个用户的身份执行命令 更改当前目录 设置环境变量 直接从PHP解释器调用PHP脚本,并将日志转储到文件中,然后通过管道将STDERS传输到/dev/null
该脚本是imo,无法转换为Windows批处理脚本,因为Windows!=POSIX,你需要重写它

那不是bash脚本!它看起来更像perl或者PHP。另外,更好的办法是描述您想要做什么,以及到目前为止您已经做了什么来尝试自己解决这个问题,而不是让我们尝试解码您的脚本谢谢Bill,这正是它所做的。我知道,这个PHP脚本在unix系统上使用,这就是为什么它使用sudo、bash等命令的原因。。。我想重写,但我真的不知道怎么做,你能帮我吗,或者给我一个学习的方法吗?感谢初学者唯一不能移植的命令是windows中的nohup和sudo。其余的应该相对容易cd linux、cd windows-用于重定向标准输出和错误-设置用于设置变量的窗口。为什么需要将其转换为windows?因为我在windows上的本地工作。我只是试图让它与cygwin一起工作,我已经删除了nohup sudo,但它仍然是一个错误。下面是$cmd:bash-cdd:\WebServer\www\MyProject\app\Plugin\Resque\Vendor\php Resque\的内容;VVERBOSE=true QUEUE=default APP\u INCLUDE=D:\WebServer\www\MyProject\APP\Plugin\Resque\Lib\ResqueBootstrap.php INTERVAL=5 CAKE=D:\WebServer\www\MyProject\Lib\CAKE\COUNT=1 php./Resque.php>D:\WebServer\www\MyProject\APP\tmp\logs\php-Resque-worker.log 2>&1&我发现以下错误:找不到指定的路径。