[英]Batch file runs with “not recognized…command”, how to fix this?
I have a batch file which when executed sets PATHs, prompts user for input and loads a script via Python. 我有一个批处理文件,该文件在执行时会设置PATH,提示用户输入并通过Python加载脚本。 The python script creates a grid with the size of each cell determined by the user input variable (
cellsize
). python脚本创建一个网格,每个网格的大小由用户输入变量(
cellsize
)确定。 The following is from my .bat file: 以下是来自我的.bat文件:
@echo off
rem Root OSGEO4W home dir to the following directory
call "C:\OSGeo4W64\bin\o4w_env.bat"
rem List available o4w programs
rem but only if osgeo4w called without parameters
@echo on
set PYTHONPATH=C:\OSGeo4W64\apps\qgis\python
set PATH=C:\OSGeo4W64\apps\qgis\bin;%PATH%
@echo off
echo.
set /p cellsize="Enter cellsize: "
cellsize=1
cmd /k python "Script.py" %cellsize%
@echo on
The .bat works the way it's supposed to, I obtain the correct results, but I receive the following error: .bat以预期的方式工作,我获得了正确的结果,但是收到以下错误:
'cellsize' is not recognized as an internal or external command, operable program or batch file
无法将“ cellsize”识别为内部或外部命令,可操作程序或批处理文件
What simple mistake(s) did I make? 我犯了什么简单的错误? I am a beginner but still learning.
我是初学者,但仍在学习。
@echo off
echo.
set /p cellsize="Enter cellsize: "
set cellsize=1
cmd /k python "Script.py" %cellsize%
@echo on
you need set
你需要
set
The line must read: 该行必须显示为:
set cellsize=1
设置单元格大小= 1
but surely this line seems more useful before the set /p line as an initialization, since otherwise it cancels the effect of that line. 但肯定此行似乎是集/ P线作为初始化之前更加有用,因为否则取消该行的效果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.