如何从批处理文件加载命令? [英] How to load commands from batch file?
问题描述
我有一个批处理文件,该文件调用了另一个用于GIS软件的批处理文件.我可以运行此命令,也可以输入一个命令来运行python
,但是如何在无需用户输入的情况下运行更多命令呢?以下是有效的脚本:
I have a batch file which calls another batch file used for GIS software. 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? 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.
推荐答案
您可以使用python script
文本的重定向
You can use redirection of the python script
text
(
echo import qgis.core
echo import qgis.gui
echo from PyQt4.QtCore import *
echo from PyQt4.QtGui import *
) | python
或者您将python代码放入第二个文件,然后使用类似的东西从批处理文件中启动该外部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 myScript.py
这篇关于如何从批处理文件加载命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!