Re: windows bat file question
Duncan Booth wrote: Peter Hansen wrote: Unfortunately, Google makes it hard to search for such things, but after a while I was able to dig up this master reference: http://www.microsoft.com/resources/documentation/windows/xp/all/proddoc s/en-us/percent.mspx You will find even more information if you try 'set /?' or 'for /?' at a command prompt. As you say, you can now do quite complicated scripting in command files but it needs masochism second only to Perl programming. As my grandmother used to say when she had made a particularly bad shot playing Crokinole, "Gah!" -- http://mail.python.org/mailman/listinfo/python-list
Re: windows bat file question
On 4 Mar 2005 10:18:08 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote: > You will find even more information if you try 'set /?' or 'for /?' at a > command prompt. As you say, you can now do quite complicated scripting in > command files but it needs masochism second only to Perl programming. And using WSH is so much easier, even JavaScript and VBScript are pleasant compared to CMD language... And of course Python can be used if appropriately installed, but then you'd probably just use Python! Alan G. Author of the Learn to Program website http://www.freenetpages.co.uk/hp/alan.gauld -- http://mail.python.org/mailman/listinfo/python-list
Re: windows bat file question
Peter Hansen wrote: > Unfortunately, Google makes it hard to search for such things, > but after a while I was able to dig up this master reference: > > http://www.microsoft.com/resources/documentation/windows/xp/all/proddoc > s/en-us/percent.mspx You will find even more information if you try 'set /?' or 'for /?' at a command prompt. As you say, you can now do quite complicated scripting in command files but it needs masochism second only to Perl programming. -- http://mail.python.org/mailman/listinfo/python-list
Re: windows bat file question
Duncan Booth wrote: Peter Hansen wrote: This should make it work: python %0.bat %* Only, among other issues, if you type the full path to the batch file, or if it's in the current directory. This approach fails if you put the batch file in a directory somewhere along your path. The simplest fix, assuming we aren't talking Win9x is probably: python "%~f0" %* Wow. The myriad things that get slipped into these little operating systems while you aren't looking. Windows XP's command shell begins to border on being marginally acceptable for some limited types of scripting. Unfortunately, Google makes it hard to search for such things, but after a while I was able to dig up this master reference: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx Thanks, Duncan! -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: windows bat file question
Peter Hansen wrote: >> This should make it work: >> python %0.bat %* > > Only, among other issues, if you type the full path to the > batch file, or if it's in the current directory. This > approach fails if you put the batch file in a directory > somewhere along your path. The simplest fix, assuming we aren't talking Win9x is probably: python "%~f0" %* > There are only a couple of useful ways to do this sort of > thing under Windows operating systems, and the easiest by > far is to abandon any support for Windows 98 and just use > the PATHEXT support in Windows NT/XP and friends. And if you can't be bothered with PATHEXT then just make sure to always type the .py in as part of the command line: C:\>myscript.py will run a Python script without any messing. If the script is in the current directory then you can use tab completion to avoid typing the whole name anyway. -- http://mail.python.org/mailman/listinfo/python-list
Re: windows bat file question
Tim Roberts wrote: Tom Willis <[EMAIL PROTECTED]> wrote: rem = """-*-Python-*- script @echo off rem DOS section rem You could set PYTHONPATH or TK environment variables here python %* This should make it work: python %0.bat %* Only, among other issues, if you type the full path to the batch file, or if it's in the current directory. This approach fails if you put the batch file in a directory somewhere along your path. There are only a couple of useful ways to do this sort of thing under Windows operating systems, and the easiest by far is to abandon any support for Windows 98 and just use the PATHEXT support in Windows NT/XP and friends. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: windows bat file question
Tom Willis <[EMAIL PROTECTED]> 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. > >rem = """-*-Python-*- script >@echo off >rem DOS section >rem You could set PYTHONPATH or TK environment variables here >python %* This should make it work: python %0.bat %* >goto exit > >""" ># Python section >import sys >from logilab.pylint import lint >lint.Run(sys.argv[1:]) > > >DosExitLabel = """ >:exit >rem """ -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: windows bat file question
Tom Willis wrote: 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. It looks like it might have been an untested version of something that should have been using "python %0 %*" at that line instead of just "python %*". Under Windows XP (and probably NT, but not 98) the %* means "all arguments", but doesn't appear (in testing just now on my own machine) to include the name of the batch file itself. On the other hand, %0 does include the name of the batch file, but unfortunately it's actually just the part that you typed, as in "blah" instead of "blah.bat" if you executed the file by typing just "blah" instead of "blah.bat". All things considered, it does look like it could never have worked properly, but Windows is freakish enough that there might well be some sequence of events and set of conditions under which it might actually work as intended... Of course, if you're on XP where you could hope that the %* magic could work at all, you can also just modify the contents of the environment variable PATHEXT to include .py, rename the script to .py and strip out all that crappy BAT stuff, and run it as intended with (almost) no complications. -Peter -- http://mail.python.org/mailman/listinfo/python-list
Re: windows bat file question
Tom Willis wrote: On Tue, 01 Mar 2005 10:12:29 -0500, Peter Hansen <[EMAIL PROTECTED]> 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/ -- http://mail.python.org/mailman/listinfo/python-list
Re: windows bat file question
On Tue, 01 Mar 2005 10:12:29 -0500, Peter Hansen <[EMAIL PROTECTED]> 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: windows bat file question
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
windows bat file question
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 -- http://mail.python.org/mailman/listinfo/python-list