Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.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 Web服务器上的Shell Exec_Php_Shell_Powershell - Fatal编程技术网

Php Web服务器上的Shell Exec

Php Web服务器上的Shell Exec,php,shell,powershell,Php,Shell,Powershell,我有一个wesbite,它使用shell exec渲染视频文件。它执行以下php代码: shell_exec('powershell -File C:\Render\templater.ps1 -v "CC 2017" -m); shell_exec('powershell -File C:\Render1\templater.ps1 -v "CC 2017" -m); 两个shell执行器的文件夹中都有自己的文件。单独执行时,它们执行良好,但当同时运行时,第二个用户命令失败。是否存在允许服务

我有一个wesbite,它使用shell exec渲染视频文件。它执行以下php代码:

shell_exec('powershell -File C:\Render\templater.ps1 -v "CC 2017" -m);
shell_exec('powershell -File C:\Render1\templater.ps1 -v "CC 2017" -m);
两个shell执行器的文件夹中都有自己的文件。单独执行时,它们执行良好,但当同时运行时,第二个用户命令失败。是否存在允许服务器运行多个shell exec调用的变通方法,或者我是否必须实现像gearman这样的队列管理器

Templater.ps1代码如下:

Param (
    [string]$v = " ",
    [switch]$ui = $false,
    [switch]$m  = $false,
    [switch]$h  = $false
)

$usage = @'
    Desc:   
        Launches Templater for Adobe After Effects
        from the command line.  A supported version of
        After Effects is required to be installed on this 
        machine for this launcher to work properly.
    Usage:
        .\templater.ps1 -v 'ae_version_string' [-ui] [-m]
    Options:
        -h
        Shows this documentation
        -v | --version 'ae_version_string'
        The version of AE you want to use with Templater, 
        where 'version_string' can be any ofthe following: 
        'CC 2017' 'CC 2015.3' 'CC 2015' 'CC 2014' 'CC' 'CS6' 'CS5.5' 'CS5'
        -ui 
        If specified, Adobe After Effects will launch with its
        graphical user interface
        -m
        If included, this causes AE to launch as a new, seperate,
        process.  This is useful if you want to simultaneously
        execute two or more versioning jobs with Templater.
    Examples:
        Launch without AE user interface

          > .\templater.ps1 -v 'CC 2015'
          > .\templater.ps1 -v 'CS5'


        Launch with AE user interface

          > .\templater.ps1 -v 'CC 2015' -ui
          > .\templater.ps1 -v 'CS5' -ui
        Launch new instance of AE without its user interface
          > .\templater.ps1 -v 'CC 2015' -m
'@


if ([string]::IsNullorWhitespace($v) -or $h -eq $true) {
    $usage
exit
}

if ($v -ne "CC 2017" -and $v -ne "CC 2015.3" -and $v -ne "CC 2015" -and $v -ne "CC 2014" -and $v -ne "CC" -and $v -ne "CS6" -and $v -ne "CS5.5" -and $v -ne "CS5") {
"
`t`tTemplater CLI Error: Please specify a valid string for the version of After Effects you want to launch. Use -h for more information.
"
exit
}

if ($ui -eq $false) {
    $ui_switch = "-noui"
} else {
    $ui_switch = " "
}

if ($m -eq $false) {
    $m_switch = " "
} else {
    $m_switch = "-m"
}

# Read templater-options.json file if it exists
if (Test-Path "$PSScriptRoot\templater-options.json"){

    $opts = Get-Content "$PSScriptRoot\templater-options.json"
    $conf = $opts -join "`n" | ConvertFrom-Json

    $log_path   = $conf.log_location
    $aep_file   = $conf.aep
    $data_src   = $conf.data_source
    $output_dir = $conf.output_location
    $output_mod = $conf.output_module
    $ftg_dir    = $conf.source_footage
    $row_start  = $conf.row_start
    $row_end    = $conf.row_end
    $pfx        = $conf.output_prefix

} else {

    echo "`nTemplater CLI configuration file 'templater-options.json' file not found.`nSee you next time :)"
    exit

}

$app_dir="C:\Program Files\Adobe\Adobe After Effects $v\Support Files"
$panels="$app_dir\Scripts\ScriptUI Panels"
$templater_filename="Templater 2.jsxbin"
$templater_panel="$panels\$templater_filename"

"`t`t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
`t`t*                                                               *
`t`t*    Templater CLI Launcher for Microsoft Windows Powershell    *
`t`t*                                                               *
`t`t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
`t`tAdobe After Effects executable
`t`t`t$app_dir\afterfx.exe
`t`tCLI configuration file =>
`t`t`t$PSScriptRoot\templater-options.json
`t`tUsing following configuration =>
`t`t`tLog Dir         : $log_path
`t`t`tAE Project      : $aep_file
`t`t`tVersioning Data : $data_src
`t`t`tFootage Dir     : $ftg_dir
`t`t`tOutput Dir      : $output_dir
`t`t`tOutput Module   : $output_mod
`t`t`tOutput Prefix   : $pfx
`t`t`tTask Range      : $row_start through $row_end
`t`tInitializing Project Directory =>
`t`t`tCopying `"$app_dir\$templater_filename`" to `"$PSScriptRoot\$templater_filename`""
Copy-Item -Force $templater_panel "$PSScriptRoot\$templater_filename"

$cmd = "$app_dir\afterfx.exe"
$cmd_args = "$ui_switch $m_switch -r  $PSScriptRoot\$templater_filename"

"
`t`tInvoking Adobe After Effects $v =>
`t`t`t$cmd $ui_switch $m_switch -r `"$PSScriptRoot\$templater_filename`"
"

$scriptblock = {

    param($cmd, $cmd_args)

    $process = New-Object system.Diagnostics.Process

    $si = New-Object System.Diagnostics.ProcessStartInfo
    $si.FileName = $cmd
    $si.Arguments = $cmd_args
    $si.UseShellExecute = $false
    $si.RedirectStandardOutput = $true

    $process.StartInfo = $si
    $process.Start() | Out-Null

    do {
        Write-Host `t`t`t $process.StandardOutput.ReadLine()
    } until ($process.HasExited)

}

Invoke-Command -ScriptBlock $scriptblock -ArgumentList $cmd, $cmd_args

if ([string]::IsNullorWhitespace($log_path)) {
    $log_path = $env:TEMP
}

"
`t`tTemplater messages and errors logged to =>
`t`t`t$log_path\templater.log
`t`t`t$log_path\templater.err
`t`tLast logged message =>
"
if (Test-Path "$log_path\templater.log"){
    Get-Content "$log_path\templater.log" | Select-Object -last 1
} else {
    "`t`t`t[No log messages]"
}
"
`t`tLast reported error =>
"
if (Test-Path "$log_path\templater.err"){
    Get-Content "$log_path\templater.err" | Select-Object -last 1
} else {
    "`t`t`t[No error messages]"
    "0"

您是否意外地让多个用户使用相同的输入或输出文件运行该命令?这将大错特错。您需要渲染到不同的文件,并且可能来自不同的输入。不,所以当我进行测试时,我同时使用以下两个命令进行测试:shell_exec('powershell-File C:\render\templater.ps1-v“CC 2017”);shell_exec('powershell-文件C:\Render2\templater.ps1-v“CC 2017”);所以它们是类似的命令,但每个命令都在自己的文件夹中。所以这并不是说他们使用的是相同的文件。php是否允许运行多个shell_exec调用(来自不同用户),前提是他们使用的文件不同?还是所有调用都转到同一个shell_exec?是否确定.ps1文件不同时使用这两个文件?您可能需要编辑问题以添加PS1文件,以便我们为您提供帮助。感谢您迄今为止的帮助。我已经添加了ps1代码。当我同时在命令行上(在不同的shell中)运行上述两个命令时,效果很好,因此我认为这与共享文件无关。