[英]How to load commands from batch file?
I have a batch file which calls another batch file used for GIS software. 我有一个批处理文件,该文件调用用于GIS软件的另一个批处理文件。 I can run this and also input a command to run python
, but how I can run more commands without having the user to input them? 我可以运行此命令,也可以输入命令来运行python
,但是如何在无需用户输入的情况下运行更多命令呢? The following is the script which works: 以下是有效的脚本:
@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.
cmd /k python
@echo on
And I would like to run the following commands automatically: 我想自动运行以下命令:
import qgis.core
import qgis.gui
from PyQt4.QtCore import *
from PyQt4.QtGui import *
Any help is greatly appreciated as I am a beginner. 由于我是新手,因此非常感谢您的帮助。
You can use redirection of the python script
text 您可以使用python script
文本的重定向
(
echo import qgis.core
echo import qgis.gui
echo from PyQt4.QtCore import *
echo from PyQt4.QtGui import *
) | python
Or you put your python code into a second file and start that external python script from your batch file with something like. 或者,您将python代码放入第二个文件,并使用类似的方法从批处理文件中启动该外部python脚本。
python myScript.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.