从 PowerShell 脚本(日志)重新启动 Apache Web 服务器
Restarting apache web server from PowerShell script (log)
我有一个 powershell 脚本可以在我的机器上重新启动 Apache Web 服务器。脚本运行正常,但是日志报错。该错误似乎来自 Powershell,而不是 Apache,因为如果我只是执行
.\httpd.exe -k config
我没有报错,第一个赞
.\http.exe -k restart
也不报错。 (注意: Powershell 在第 11 行抱怨,而不是第 10 行 httpd.exe 的第一次调用)。我在 Windows 7.
上使用 powershell V4
所以我想了解 Powershell 在这里做什么,因为我认为 Apache 工作正常。
这是脚本:
# This PowerShell script restarts apache
start-transcript -Path install.log -Append
Write-Host "apache.ps1 Script`r`n"
$sixtyfour = [Environment]::Is64BitProcess
$exe = "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe"
Write-Host "64-Bit Powershell: "$sixtyfour
& $exe -k restart *>> install.log
Write-Host ""
& $exe -k config *>> install.log
这是日志:
httpd.exe : Reconfiguring the Apache2.2 service
At G:\wwwroot\setup\apache.ps1:11 char:1
+ & $exe -k config *>> install.log
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Reconfiguring the Apache2.2 service:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
The Apache2.2 service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
刚刚发现有关将错误重定向到字符串的信息。请参阅答案 #2:
Error when calling 3rd party executable from Powershell when using an IDE
它指向您:
$LastExitCode=0 but $?=False in PowerShell. Redirecting stderr to stdout gives NativeCommandError
我有一个 powershell 脚本可以在我的机器上重新启动 Apache Web 服务器。脚本运行正常,但是日志报错。该错误似乎来自 Powershell,而不是 Apache,因为如果我只是执行
.\httpd.exe -k config
我没有报错,第一个赞
.\http.exe -k restart
也不报错。 (注意: Powershell 在第 11 行抱怨,而不是第 10 行 httpd.exe 的第一次调用)。我在 Windows 7.
上使用 powershell V4所以我想了解 Powershell 在这里做什么,因为我认为 Apache 工作正常。
这是脚本:
# This PowerShell script restarts apache
start-transcript -Path install.log -Append
Write-Host "apache.ps1 Script`r`n"
$sixtyfour = [Environment]::Is64BitProcess
$exe = "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe"
Write-Host "64-Bit Powershell: "$sixtyfour
& $exe -k restart *>> install.log
Write-Host ""
& $exe -k config *>> install.log
这是日志:
httpd.exe : Reconfiguring the Apache2.2 service
At G:\wwwroot\setup\apache.ps1:11 char:1
+ & $exe -k config *>> install.log
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Reconfiguring the Apache2.2 service:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
The Apache2.2 service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
刚刚发现有关将错误重定向到字符串的信息。请参阅答案 #2:
Error when calling 3rd party executable from Powershell when using an IDE
它指向您:
$LastExitCode=0 but $?=False in PowerShell. Redirecting stderr to stdout gives NativeCommandError