474,116 Members | 2,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ar gv[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\myp roject\pylint mymodule.py

Any ideas?

--
Thomas G. Willis
http://paperbackmusic.net
Jul 18 '05 #1
11 3315
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
Jul 18 '05 #2
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
Jul 18 '05 #3
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/
Jul 18 '05 #4
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
Jul 18 '05 #5
Tom Willis <to********@gma il.com> 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.a rgv[1:])
DosExitLabel = """
:exit
rem """

--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 18 '05 #6
Tim Roberts wrote:
Tom Willis <to********@gma il.com> 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
Jul 18 '05 #7
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.

Jul 18 '05 #8
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/d...s/percent.mspx

Thanks, Duncan!

-Peter
Jul 18 '05 #9
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/d...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.

Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
7102
by: sebastien.hugues | last post by:
Hi I would like to retrieve the application data directory path of the logged user on windows XP. To achieve this goal i use the environment variable APPDATA. The logged user has this name: sébastien. The second character is not an ascii one and when i try to encode the path that contains this name in utf-8,
2
1421
by: mio | last post by:
Hi We have a WEB-based application (developed in Visual Studio 2005) running on handheld devices in Internet Explorer on Windows Mobile 2003. The application needs to print tickets on a Bluetooth printer, which is accomplished by preparing a RTF-file on the server and then downloading this file to the handheld device. We use a third-party application (PrintPocketCE from FieldSoftware) for the actual printing of the downloaded file....
54
9061
by: Sathyaish | last post by:
I am trying to print to the printer. I am using a VC++ 6.0 compiler on Win 2K, but I get an error saying that stdprn is not defined. Why is that? Is it because of Windows, I am guessing? Do I have to use only the GDI32 functions for printing under Windows? Can I not use the stdprn under Windows to print from memory to the window?
7
5829
by: Luc The Perverse | last post by:
Hello! I am looking for a beginners tutorial on how to program for windows in C. I guess this is windows API? I have never written outside of VC++ for windows, and can't find any examples. I don't think that this is a DevC++ specific question. I have written a simple application which locates duplicate files; it first compares file sizes, and then runs an SHA-256 (might switch to Adler 32)
3
15079
by: Amjad | last post by:
Hi, I just wrote a test Windows Service that creates a text file on startup (please see my code below). The file is never created. Protected Overrides Sub OnStart(ByVal args() As String) Dim swLog As StreamWriter = File.CreateText("C:\myLog.txt") swLog.WriteLine("My Windows Service has just started.") swLog.Close() : swLog.Flush() End Sub
0
1287
by: tony | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file. One project that build a class library dll One project that build a windows control dll In the windows control c-tor is there a call to a method in the class libarary. So in the project referense settings for the windows control I have a
6
595
by: Chris Marsh | last post by:
All I have a database table, changes to the data within which I am interested in acting on. The approach that I'm taking is to have the database update a file every time data is updated. This process is outside my domain - I can rely on the file being updated when data changes. Within my domain is the design of a Windows service to perform the operations required when the data changes. I have not produced a Windows service before...
60
8122
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I prompt a "Save As" dialog for an accepted mime type? ----------------------------------------------------------------------- It is not possible with client-side JavaScript. Some browsers accept the Content-Disposition header, but this must be added by the server. Taking the form:- ` Content-Disposition: attachment; filename=filename.ext `
1
4606
by: CSharpner | last post by:
Short Question: How do I support Cut/Paste to/from a .NET app and Windows Explorer? Full Text: I'm nearing the completion of a Remote File Management application. It looks and feels a lot like Windows Explorer. The difference is that it communicates with a remote server via web services. The remote web services store and retrieve the file bits to/from a database... along with some other bells and whistles that Explorer doesn't have.
5
3336
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name? Why do I need to set a property within my code to the service name? Are all these required or am I just doing this for consistency purposes?
0
11749
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
12389
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
11278
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8894
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
6889
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
7031
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
5605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
5085
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
4175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.