Hello,
I want to compile that small python script:
bastet:/ # cat test.py
#!/usr/bin/python
import sys, os
username = os.getlogin()
print username
os.spawnv(os.P_ WAIT, "/root/mailboxmgm.py", sys.argv)
Python 2.3.2 (#1, Oct 12 2003, 14:27:24)
[GCC 3.2] on linux2
Type "help", "copyright" , "credits" or "license" for more information. import py_compile py_compile.comp ile("test.py")
bastet:/ # chmod u+x test.pyc
bastet:/ # ./test.pyc
../test.pyc: line 1: syntax error near unexpected token `;'
'/test.pyc: line 1: `;ò
bastet:/ #
What is wrong?
Thanks,
Florian 3 2180
Florian Lindner wrote: I want to compile that small python script:
... bastet:/ # chmod u+x test.pyc bastet:/ # ./test.pyc ./test.pyc: line 1: syntax error near unexpected token `;' '/test.pyc: line 1: `;ò bastet:/ #
What is wrong?
A compiled Python file (.pyc) is not an executable. (Specifically, in
the Unix world, it does not contain a bangpath.) Instead, just pass it
as an argument to the Python interpreter:
max@oxygen:~/tmp% cat > hello.py
print "Hello, world!"
^D
max@oxygen:~/tmp% python
Python 2.3.3 (#1, Dec 22 2003, 23:44:26)
[GCC 3.2.3] on linux2
Type "help", "copyright" , "credits" or "license" for more information. import py_compile py_compile.comp ile('hello.py') ^D
max@oxygen:~/tmp% ls hello.py*
hello.py hello.pyc
max@oxygen:~/tmp% rm hello.py
max@oxygen:~/tmp% python hello.pyc
Hello, world!
--
__ Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
\__/ Granted that I must die, how shall I live?
-- Michael Novak
Erik Max Francis wrote: Florian Lindner wrote:
I want to compile that small python script: ... bastet:/ # chmod u+x test.pyc bastet:/ # ./test.pyc ./test.pyc: line 1: syntax error near unexpected token `;' '/test.pyc: line 1: `;ò bastet:/ #
What is wrong?
A compiled Python file (.pyc) is not an executable. (Specifically, in the Unix world, it does not contain a bangpath.) Instead, just pass it as an argument to the Python interpreter:
max@oxygen:~/tmp% cat > hello.py print "Hello, world!" ^D max@oxygen:~/tmp% python Python 2.3.3 (#1, Dec 22 2003, 23:44:26) [GCC 3.2.3] on linux2 Type "help", "copyright" , "credits" or "license" for more information. import py_compile py_compile.comp ile('hello.py') ^D
max@oxygen:~/tmp% ls hello.py* hello.py hello.pyc max@oxygen:~/tmp% rm hello.py max@oxygen:~/tmp% python hello.pyc Hello, world!
Can I run these scripts under another UID than the user executing them?
(SUID)
Thx,
Florian
see Misc/setuid-prog.c in the Python source distribution.
Jeff This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jeremy Fincher |
last post by:
I'm having problems compiling Python with socket support (and support
for several other libraries) on Solaris 7.
When I do the standard ./configure, make, make install dance, I got a
fully compiled Python without an _socket module.
So I uncommented the appropriate socketmodule.c line in Modules/Setup,
and recompiled.
I get this:
|
by: Olaf Meyer |
last post by:
I'm having some problems compiling Python 2.3.3 on HP-UX (B.11.00).
I've tried sevral different options for the configure script (e.g.
enabling/disabling gcc, aCC) but I always get the same problem during
the final linking stage. Several PyThread_* symbols are undefined (for
details see the output below).
In order to get DCOracle2 support working I've also set the LDFLAGS
environment variable to "-lpthread -lcl" (as mentioned in the...
|
by: Maurice LING |
last post by:
Hi,
I remembered reading a MSc thesis about compiling Perl to Java bytecodes
(as in java class files). At least, it seems that someone had compiled
scheme to java class files quite successfully. I'm wondering if
something of such had been attempted in python, as in compiling X
language into .pyc. I do not understand the schematics of .pyc files but
I assume that they are the so called python bytecode files.
Or is there any...
|
by: Jeff Hagelberg |
last post by:
I'm trying to create a python module which can be used by a python
interpreter embedded inside a fortran program I have. To do this, I
first created python wrappers for all the functions in my fortran
program using f2py. I then start an embedded python interpreter in c
code which I link against the fortran program. I invoke the fortran
program with a filename containing python code. This file is passed
to the c code which passes it on...
|
by: ivan.pavlov |
last post by:
I am running Debian/Linux unstable. Trying to upgrade packages
depending on python (via aptitude) has started to give errors and
leaves all packeges unconfigured. When I run dpkg --configure pyhton2.3
the following errors occur.
Any advice on what to do?
Setting up python2.3 (2.3.5-8) ...
Compiling python modules in /usr/lib/python2.3 ...
Compiling /usr/lib/python2.3/site-packages/srcb/generator.py ...
| |
by: Brian |
last post by:
First off, I am sorry for cluttering this group with my inept
questions, but I am stuck again despite a few hours of hair pulling.
I have a function (below) that takes a list of html pages that have
images on them (not porn but boats). This function then (supposedly)
goes through and extracts the links to those images and puts them into
a list, appending with each iteration of the for loop. The list of
html pages is 82 items long and...
|
by: metaperl |
last post by:
I've tried both Python 2.4.4 and Python 2.5. I'm trying to build from
source and install under a local directory Swarm since OpenSwarm
requires builds of Postgres and Python under it's control.
Ok, so I did
../configure --prefix=/Users/tbrannon/Documents/Python/Swarm/Python-2.5
but during make install I get this:
|
by: John Nagle |
last post by:
I've been installing Python and its supporting packages on
a dedicated server with Fedora Core 6 for about a day now.
This is a standard dedicated rackmount server in a colocation
facility, controlled via Plesk control panel, and turned over
to me with Fedora Core 6 in an empty state. This is the
standard way you get a server in a colo today.
Bringing Python up in this completely clean environment is
a huge hassle, and it doesn't...
|
by: Yansky |
last post by:
I asked my hosting company if they would upgrade Python on my server
to the latest version. They responded with:
"Sorry no. We tend to stick with what comes packaged with the unix
distribution to ease maintenance issues.
There is nothing stopping you from running your own version of python
from within your own account. Download the source and compile it and
install it into your own space. Adjust the fist line of your python
scripts to...
|
by: F. |
last post by:
Hello,
I have problems making python on CentOS 5.
Seems that can not find something. I can not find the problem.
Where is the problem?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |