473,321 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Re: Converting .py files to batch files.

aditya shukla escribió:
How can we convert .py files to batch files? is there any library for this?
Aditya
------------------------------------------------------------------------

--
http://mail.python.org/mailman/listinfo/python-list
Maybe py2exe can help you.

Sep 15 '08 #1
5 6707
On Sep 15, 3:04 pm, Matias Surdi <matiassu...@gmail.comwrote:
aditya shukla escribió:
How can we convert .py files to batch files? is there any library for this?
Aditya
------------------------------------------------------------------------
--
http://mail.python.org/mailman/listinfo/python-list

Maybe py2exe can help you.
I assume you are on Windows? Let's assume you have a file stuff.py
that reads:

import os
print os.listdir('.') # list current directory, good enough for
testing...

Then, insert the following line at the top:

@setlocal enableextensions & python -x %~f0 %* & goto :EOF

Now save this file as stuff.cmd somewhere along your PATH. Now calling
'stuff' should execute your file.
On Linux, you would instead insert the shebang line that points to
your python interpreter, such as

#!/usr/bin/python

at the top and also set the executable bit, but I suppose if you use
Linux at all you know that.
Sep 15 '08 #2
En Mon, 15 Sep 2008 20:36:05 -0300, Michael Palmer <m_********@yahoo.ca>
escribió:
>aditya shukla escribió:
How can we convert .py files to batch files? is there any library for
this?

I assume you are on Windows? Let's assume you have a file stuff.py
that reads:

import os
print os.listdir('.') # list current directory, good enough for
testing...

Then, insert the following line at the top:

@setlocal enableextensions & python -x %~f0 %* & goto :EOF

Now save this file as stuff.cmd somewhere along your PATH. Now calling
'stuff' should execute your file.
Cool! I'd enclose the first argument in quotes "%~f0" - in case the path
contains any whitespace.

--
Gabriel Genellina

Sep 16 '08 #3
r0g
Michael Palmer wrote:
On Sep 15, 3:04 pm, Matias Surdi <matiassu...@gmail.comwrote:
>aditya shukla escribió:
>>How can we convert .py files to batch files? is there any library for this?
Aditya
------------------------------------------------------------------------
<snip>On Linux, you would instead insert the shebang line that points to
your python interpreter, such as

#!/usr/bin/python

at the top and also set the executable bit, but I suppose if you use
Linux at all you know that.
Doh! I'm new to Linux and so I didn't know that, thanks!
One small snag though, it doesn't work on my system :-(
I did both steps, the shebang and the execute bit but nada...

r0g@steppa:~/Desktop/py$ ls
kickstart.py kickstart.py~ kicktest.py kicktest.py~
r0g@steppa:~/Desktop/py$ kickstart.py
bash: kickstart.py: command not found

Any ideas why this might be? A path thing? I'm on Ubuntu 8.04 / Py2.5

Thanks,

Roger.
Sep 17 '08 #4
On 2008-09-17, r0g <ai******@technicalbloke.comwrote:
r0g@steppa:~/Desktop/py$ ls
kickstart.py kickstart.py~ kicktest.py kicktest.py~
r0g@steppa:~/Desktop/py$ kickstart.py
bash: kickstart.py: command not found

Any ideas why this might be?
Yes.
A path thing?
Yes.

Linux systems generally don't have the current directory in the
PATH that's searched for executbles (it's regarded as a rather
serious security problem if you do).

Try doing this:

./kickstart.py

--
Grant Edwards grante Yow! Look into my eyes and
at try to forget that you have
visi.com a Macy's charge card!
Sep 17 '08 #5
r0g
Grant Edwards wrote:
On 2008-09-17, r0g <ai******@technicalbloke.comwrote:
>r0g@steppa:~/Desktop/py$ ls
kickstart.py kickstart.py~ kicktest.py kicktest.py~
r0g@steppa:~/Desktop/py$ kickstart.py
bash: kickstart.py: command not found

Any ideas why this might be?

Yes.
>A path thing?

Yes.

Linux systems generally don't have the current directory in the
PATH that's searched for executbles (it's regarded as a rather
serious security problem if you do).

Try doing this:

./kickstart.py
Brilliant! :D Thanks v.much for that, turns out the very same thing had
been driving me nuts a few days earlier when I was trying to run an
installer I had downloaded, bit of an Izzard Printer moment LOL -
http://www.youtube.com/watch?v=2wHEqDepAXo

Thanks again!

Roger.

http://www.technicalbloke.com
http://movingtoubuntu.technicalbloke.co.uk
Sep 17 '08 #6

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

Similar topics

1
by: Bernhard Sollfrank | last post by:
Hello, i have to start a batch process from a dll to transfer files created by this dll to remote ftp server. I created a batch file: ftp -n -v -i -s:D:\batch\ftpcmds.txt ftp-server and a...
2
by: Herb Stevenson | last post by:
Hello all. I need to set up a batch file to work w/ the Visual Studio.NET 2003 command prompt. However, when I run the batch file it uses the standard command prompt. Is there a way to...
7
by: erniedude | last post by:
Hi, I'm a newbie and I was wondering if anyone knew a (Python) script to run 4 batch files, one after the other (assuming the directories are known). It would be better if all 4 batch files...
3
by: j.a. harriman | last post by:
Hi, On MSDN I know there is a JScript example (Upgrading Visual C++ Projects to Visual Studio .NET in Batch Mode) to upgrade VS6 C++ projects to .NET solutions. It converts the project files...
0
by: Steve Jorgensen | last post by:
I remember that I used to set up utility batch files, and create Windows shortcuts to them that would ask the user for parameters to supply to the batch files. From what I can tell, this...
5
by: gwarning! | last post by:
Goal: Have multiple text files, each of various lengths, be concatenated together into one final consolidated text file. Problem: Since the names of the files to be concatenated can change from...
1
by: Mario Crevits | last post by:
My name is Mario Crevits, I'm from Belgium (Roeselare) and I'm working with Access97 for several years now. We are in an Access97-2000 migration project. I'm writing a wizard for the end-users to...
6
by: Charles Neitzel | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
1
by: Charles | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running...
0
by: Chris Rebert | last post by:
On Mon, Sep 15, 2008 at 10:30 AM, aditya shukla <adityashukla1983@gmail.comwrote: Unless your Python scripts are essentially just *really basic* shell scripts that happen to be written in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.