Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #96811 > unrolled thread

.bat file trouble.

Started bybobertini@googlemail.com
First post2015-09-18 02:06 -0700
Last post2015-09-20 09:43 -0600
Articles 5 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  .bat file trouble. bobertini@googlemail.com - 2015-09-18 02:06 -0700
    Re: .bat file trouble. Steven D'Aprano <steve@pearwood.info> - 2015-09-18 19:32 +1000
    Re: .bat file trouble. Christian Gollwitzer <auriocus@gmx.de> - 2015-09-18 15:45 +0200
      Re: .bat file trouble. eryksun <eryksun@gmail.com> - 2015-09-20 09:53 -0500
      Re: .bat file trouble. Ian Kelly <ian.g.kelly@gmail.com> - 2015-09-20 09:43 -0600

#96811 — .bat file trouble.

Frombobertini@googlemail.com
Date2015-09-18 02:06 -0700
Subject.bat file trouble.
Message-ID<d4e0dfd5-a87e-49a4-9a7c-696aabf527f2@googlegroups.com>
Hi,

I have two files called module_scripts.py and build_q_scripts.bat.

The problem being that when I go to run the bat file it produces a few errors which neither myself or the original owner of the files could understand.

Errors:

https://gyazo.com/c680f0d70cefe855c21ab0882d7c17b7

We originally thought that it was because it was missing the files: process_init.py and process_global_variables.py however they are right there in the same directory.

File contents for the bat file:

@echo off
python process_init.py
python process_global_variables.py
python process_scripts.py
@del *.pyc
echo.
echo ______________________________
echo.
echo Script processing has ended.
echo Press any key to exit. . .
pause>nul

If there is anyone with any idea how to fix it I'd love you forever :)

[toc] | [next] | [standalone]


#96812

FromSteven D'Aprano <steve@pearwood.info>
Date2015-09-18 19:32 +1000
Message-ID<55fbda36$0$1646$c3e8da3$5496439d@news.astraweb.com>
In reply to#96811
On Fri, 18 Sep 2015 07:06 pm, bobertini@googlemail.com wrote:

> Hi,
> 
> I have two files called module_scripts.py and build_q_scripts.bat.
> 
> The problem being that when I go to run the bat file it produces a few
> errors which neither myself or the original owner of the files could
> understand.

Can you copy and paste the errors? I presume that they are words rather than
pictures. That way, people who use a screen reader can hear them, and so
can people who aren't able or willing to click on random URLs to strange
websites that will do who knows what.


> Errors:
> 
> https://gyazo.com/c680f0d70cefe855c21ab0882d7c17b7

I get: 

SSL error:host(gyazo.com)!=cert(*.gyazo.com)

and when I continue, I get:

Your browser is not supported in Gyazo.


so I'm afraid I cannot help you further unless I guess:

> We originally thought that it was because it was missing the files:
> process_init.py and process_global_variables.py however they are right
> there in the same directory.

I'm going to look into my crystal ball and see what the spirits say...

They say... 

- is it a permissions problem? 

- is it a path problem? 

- what happens if you run this batch file instead?

@echo off
python -c "import sys; print(sys.version)"
echo Press any key to exit. . .
pause>nul


Is the printed version the version you expect?


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#96822

FromChristian Gollwitzer <auriocus@gmx.de>
Date2015-09-18 15:45 +0200
Message-ID<mth4e7$atq$1@dont-email.me>
In reply to#96811
Am 18.09.15 um 11:06 schrieb bobertini@googlemail.com:
> Hi,
>
> I have two files called module_scripts.py and build_q_scripts.bat.
>
> The problem being that when I go to run the bat file it produces a
> few errors which neither myself or the original owner of the files
> could understand.
>
> Errors:
>
> https://gyazo.com/c680f0d70cefe855c21ab0882d7c17b7

The first error indicates, that you are running Python 3, and the script 
was made for Python 2. In Python 3, print is a function so you need 
parentheses around that print("Initializing...") - either fix that
or install Python 2.

The second error "TabError" also relates to it, it means that the file 
mixes tabs and spaces for indentation. Fix it by expanding all tabs to 
spaces in an editor.

> We originally thought that it was because it was missing the files:
> process_init.py and process_global_variables.py however they are
> right there in the same directory.


Concerning that, windows usually runs a .bat file in the directory where 
it is situated, so putting the python fies there /should/ work, but you 
can also set this using the right-click menu (execute in...), if you 
make a link to the desktop.

	Christian

[toc] | [prev] | [next] | [standalone]


#96880

Fromeryksun <eryksun@gmail.com>
Date2015-09-20 09:53 -0500
Message-ID<mailman.40.1442760834.21674.python-list@python.org>
In reply to#96822
On 9/18/15, Christian Gollwitzer <auriocus@gmx.de> wrote:
> Am 18.09.15 um 11:06 schrieb bobertini@googlemail.com:
>
>> We originally thought that it was because it was missing the files:
>> process_init.py and process_global_variables.py however they are
>> right there in the same directory.
>
> Concerning that, windows usually runs a .bat file in the directory where
> it is situated, so putting the python fies there /should/ work, but you
> can also set this using the right-click menu (execute in...), if you
> make a link to the desktop.

It's fragile to depend on being started by Explorer or a shell link.
For example, if the batch is run from an existing cmd shell, then it
runs with cmd's current working directory. Or another process could
run the batch file with a different working directory. If you actually
want the batch to find the scripts relative to its own directory, then
it should use the %0 environment variable, which references the
fully-qualified path of the batch file. Getting just the directory,
i.e. its [d]rive and [p]ath, is expressed as %~dp0. Note that this
path includes a trailing backslash.

[toc] | [prev] | [next] | [standalone]


#96882

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-09-20 09:43 -0600
Message-ID<mailman.41.1442763841.21674.python-list@python.org>
In reply to#96822
On Fri, Sep 18, 2015 at 7:45 AM, Christian Gollwitzer <auriocus@gmx.de> wrote:
> The first error indicates, that you are running Python 3, and the script was
> made for Python 2. In Python 3, print is a function so you need parentheses
> around that print("Initializing...") - either fix that
> or install Python 2.
>
> The second error "TabError" also relates to it, it means that the file mixes
> tabs and spaces for indentation. Fix it by expanding all tabs to spaces in
> an editor.

Note that even if you fix these, there could be other less obvious
compatibility issues with running this script in Python 3. The safest
and most straightforward way to proceed is to install Python 2 and use
that to run the script. However, in the long term you may want to
consider upgrading the script to Python 3 anyway. Python 2.7 is only
guaranteed to be supported through the year 2020.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web