运行此代码后,我期望仅收到输出“ *没有用户存在”:
FOR /F "tokens=* delims= " %%A IN ('C:\windows\System32\query.exe user /server:<some_IP_address>') DO SET NumDoc1=%%A
echo %NumDoc1%
但我不断得到:
No User exists for *
ECHO is off.
如何从输出中消除“ ECHO关闭”?
谢谢
答案 0 :(得分:3)
您NUKE_PATH = os.environ['NUKE_PATH']
l = NUKE_PATH.split(';')
result = filter(lambda path: "tk-nuke-writenode" in path, l)
处于当前path = 'X:\pipeline\app_config\release\extensions\global\nuke;X:\pipeline\app_config\release\extensions\projects\sgtk\powerPlant\install\app_store\tk-nuke\v0.11.4\classic_startup\restart;X:/pipeline/app_config/release/extensions/projects/sgtk/powerPlant/install/app_store/tk-nuke-writenode/v1.4.1/gizmos'
matches = [p for p in path.split(';') if 'tk-nuke-writenode' in p]
matches[0]
'X:/pipeline/app_config/release/extensions/projects/sgtk/powerPlant/install/app_store/tk-nuke-writenode/v1.4.1/gizmos'
状态,因为您的变量为空。
尝试以下方法:
echo
答案 1 :(得分:3)
未找到用户时,输出将发送到“标准错误”。 FOR命令只是捕获标准输出。因此,您需要将标准错误重定向到标准输出。
for /f "delims=" %%G IN ('"query user /server:servername 2>&1"') do set NumDoc1=%%G