windows bat文件问题 [英] windows bat file question

查看:84
本文介绍了windows bat文件问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在窗口上运行pylint和它的bat文件

似乎有点棘手。我希望有人可能已经想出了这个




rem =""" - * - Python - * - script

@echo off

rem -------------------- DOS部分--------- -----------

rem你可以在这里设置PYTHONPATH或TK环境变量

python%*

转到退出


"""

#-------------------- Python部分 - -------------------

import sys
来自logilab.pylint的
import lint

lint.Run(sys.argv [1:])

DosExitLabel ="""

:exit

rem" "


我得到的是python提示符,从import sys开始的行不要运行
。如果我在python脚本中抛出这些行,我会遇到路径问题。


我想要实现的整体效果是....

c:\Projects\myproject\pylint mymodule.py


有什么想法吗?


-

Thomas G. Willis
http://paperbackmusic.net

解决方案

Tom Willis写道:

我正在尝试在窗口上运行pylint并为它执行bat文件 ...
所有我得到的是python提示,从import sys开始的行不要
跑。如果我在python脚本中抛出这些行,我会遇到路径问题。




你打算尝试运行它的确切命令是什么?

相对于当前目录的脚本在哪里? (最好是

剪切并粘贴实际命令行的副本和结果
你在控制台中的
。)


关于路径问题的主题在另一种情况下,你对路径问题意味着什么?b $ b意味着什么? DOS路径问题? sys.path问题?东西

别的?究竟有什么问题...


-Peter


2005年3月1日星期二10:12:29 -0500,彼得Hansen< pe *** @ engcorp.com>写道:

汤姆威利斯写道:

我正试图在窗口上运行pylint并且它的bat文件似乎有点棘手。我希望有人可能已经想到了这个。
...
所有我得到的是python提示,从import sys开始的行不要
跑。如果我在python脚本中抛出这些行,我会遇到路径问题。



为了尝试运行它,你键入了什么确切的命令?
相对于当前目录的脚本在哪里? (最好是剪切并粘贴您在控制台中的实际命令行和结果的副本。)

关于路径问题的主题。在另一种情况下,你对路径问题意味着什么? DOS路径问题? sys.path问题?还有别的东西吗?究竟是什么问题...

-Peter
-
http://mail.python.org/mailman/listinfo/python-list




我认为它出。我刚刚使用随附的

批处理文件中的嵌入式python代码并将其放入其自己的模块中。


真的是我的问题这是怎么回事?在我看来,这很简单,但是要知道这是否是某种类型的会议是很方便的,如果我写的东西,我可以利用它

需要在windoze上运行。

REM --- bat文件---

rem =""" - * - Python - * - 脚本

@echo off

rem -------------------- DOS部分--------------------

rem你可以在这里设置PYTHONPATH或TK环境变量

python%*

转到退出


"""

#-------------- ------ Python部分--------------------

print" hello from python"

DosExitLabel ="""

:退出

rem""

REM ---蝙蝠文件结束---


我想知道这是否利用了批处理文件中的一些缺陷

处理不能再使用因为一些安全漏洞

堵塞了什么。


-

Thomas G. Willis
http://paperbackmusic.net


Tom Willis写道:

星期二,2005年3月1日10:12:29 -0500,Peter Hansen< pe *** @ engcorp.com>写道:

Tom Willis写道:

我正在尝试在窗口上运行pylint并为其执行bat文件
看起来有点棘手。我希望有人可能已经想到了这个。
...
所有我得到的是python提示,从import sys开始的行不要
跑。如果我在python脚本中抛出这些行,我会遇到路径问题。



为了尝试运行它,你键入了什么确切的命令?
相对于当前目录的脚本在哪里? (最好是剪切并粘贴您在控制台中的实际命令行和结果的副本。)

关于路径问题的主题。在另一种情况下,你对路径问题意味着什么? DOS路径问题? sys.path问题?还有别的东西吗?究竟是什么问题...

-Peter
-
http://mail.python.org/mailman/listinfo/python-list



我明白了。我只是把随附的
批处理文件中的嵌入式python代码放在​​它自己的模块中。

真的我的问题是这将如何工作?在我看来,它有点麻烦,但是如果我曾经写过一些可以利用的东西,那么我可以利用它将会很有用,这将是很方便的。需要在windoze上运行。

REM --- bat文件---
rem =""" - * - Python - * - script
@echo off
rem -------------------- DOS部分--------------------
你可以在这里设置PYTHONPATH或TK环境变量
python%*
goto exit

"""
#------- ------------- Python部分--------------------
print" hello from python"

DosExitLabel ="""
:退出
rem""
REM ---结束蝙蝠文件---

我想知道这是否利用了批处理文件处理中的一些缺陷,因为某些安全漏洞已被堵塞或其他东西而无法再使用。



显然最初的意图以名称的形式运行然后将

批处理文件传递给Python解释器,但至于它实际上应该如何工作,你的猜测和我的一样好。 />

问候

Steve

-

与Python开发人员和你的clpy收藏会面3月23日 - 25

来到PyCon DC 2005 http://www.pycon.org /

Steve Holden http://www.holdenweb。 com /


I''m trying to get pylint running on windows and the bat file for it
seems a little screwy. I''m hoping someone may have figured this out
already.

rem = """-*-Python-*- script
@echo off
rem -------------------- DOS section --------------------
rem You could set PYTHONPATH or TK environment variables here
python %*
goto exit

"""
# -------------------- Python section --------------------
import sys
from logilab.pylint import lint
lint.Run(sys.argv[1:])
DosExitLabel = """
:exit
rem """

All I get is the python prompt, the lines starting at import sys don''t
run. If I throw the lines in a python script, I run into path issues.

The overall effect I''m trying to achieve is....

c:\Projects\myproject\pylint mymodule.py

Any ideas?

--
Thomas G. Willis
http://paperbackmusic.net

解决方案

Tom Willis wrote:

I''m trying to get pylint running on windows and the bat file for it
seems a little screwy. I''m hoping someone may have figured this out
already.
...
All I get is the python prompt, the lines starting at import sys don''t
run. If I throw the lines in a python script, I run into path issues.



What exact command are you typing to try to run it? Where is
the script relative to the current directory? (Best is to
cut and paste a copy of the actual command line and result
that you have in your console.)

On the topic of the "path issues" in the other case, what do you
mean by path issues? DOS path issues? sys.path issues? Something
else? What issues exactly...

-Peter


On Tue, 01 Mar 2005 10:12:29 -0500, Peter Hansen <pe***@engcorp.com> wrote:

Tom Willis wrote:

I''m trying to get pylint running on windows and the bat file for it
seems a little screwy. I''m hoping someone may have figured this out
already.
...
All I get is the python prompt, the lines starting at import sys don''t
run. If I throw the lines in a python script, I run into path issues.



What exact command are you typing to try to run it? Where is
the script relative to the current directory? (Best is to
cut and paste a copy of the actual command line and result
that you have in your console.)

On the topic of the "path issues" in the other case, what do you
mean by path issues? DOS path issues? sys.path issues? Something
else? What issues exactly...

-Peter
--
http://mail.python.org/mailman/listinfo/python-list



I figured it out. I just took the embedded python code that was in the
batch file distributed with it and put it in it''s own module.

Really my question was how would this ever work? It seems to me to be
a little screwy, but it would be handy to know if this was some sort
of convention that I could take advantage of if I ever write something
substantial that would need to run on windoze.
REM---bat file---
rem = """-*-Python-*- script
@echo off
rem -------------------- DOS section --------------------
rem You could set PYTHONPATH or TK environment variables here
python %*
goto exit

"""
# -------------------- Python section --------------------
print "hello from python"

DosExitLabel = """
:exit
rem """
REM---end of bat file---

I''m wondering if this took advantage of some flaw in batch file
processing that can no longer be used because of some security hole
that got plugged or something.


--
Thomas G. Willis
http://paperbackmusic.net


Tom Willis wrote:

On Tue, 01 Mar 2005 10:12:29 -0500, Peter Hansen <pe***@engcorp.com> wrote:

Tom Willis wrote:

I''m trying to get pylint running on windows and the bat file for it
seems a little screwy. I''m hoping someone may have figured this out
already.
...
All I get is the python prompt, the lines starting at import sys don''t
run. If I throw the lines in a python script, I run into path issues.



What exact command are you typing to try to run it? Where is
the script relative to the current directory? (Best is to
cut and paste a copy of the actual command line and result
that you have in your console.)

On the topic of the "path issues" in the other case, what do you
mean by path issues? DOS path issues? sys.path issues? Something
else? What issues exactly...

-Peter
--
http://mail.python.org/mailman/listinfo/python-list


I figured it out. I just took the embedded python code that was in the
batch file distributed with it and put it in it''s own module.

Really my question was how would this ever work? It seems to me to be
a little screwy, but it would be handy to know if this was some sort
of convention that I could take advantage of if I ever write something
substantial that would need to run on windoze.
REM---bat file---
rem = """-*-Python-*- script
@echo off
rem -------------------- DOS section --------------------
rem You could set PYTHONPATH or TK environment variables here
python %*
goto exit

"""
# -------------------- Python section --------------------
print "hello from python"

DosExitLabel = """
:exit
rem """
REM---end of bat file---

I''m wondering if this took advantage of some flaw in batch file
processing that can no longer be used because of some security hole
that got plugged or something.


It was clearly originally intended to be run as "name" and then pipe the
batch file into the Python interpreter, but as to how the hell it was
actually supposed to work, your guess is as good as mine.

regards
Steve
--
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005 http://www.pycon.org/
Steve Holden http://www.holdenweb.com/


这篇关于windows bat文件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆