[英]execute a multi line shell comand in PHP
I'm trying to get user email of current user using command line.我正在尝试使用命令行获取当前用户的用户 email。 In Powershell i paste these lines and it works在 Powershell 我粘贴这些行并且它工作
>> $searcher = [ADSISearcher] "(sAMAccountName=$env:USERNAME)"
>> $searcher.PropertiesToLoad.AddRange(@("mail"))
>> $searcher.FindOne().Properties["mail"][0]
test@gmail.com
but when i try to do this in php with exec or shell_exec但是当我尝试在 php 中使用 exec 或 shell_exec 执行此操作时
$cmd=<<<CMD
$searcher = [ADSISearcher] "(sAMAccountName=$env:USERNAME)" \
$searcher.PropertiesToLoad.AddRange(@("mail")) \
$searcher.FindOne().Properties["mail"][0]
CMD;
print_r(shell_exec($cmd));
it shows me errors undefined variable searcher它向我显示错误未定义的变量搜索器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.