Hopefully this is a simple question. I've started to program in Python
after an absence of about a year, so I'm very rusty. I wrote a short
program and tried to run it using Python2.4 in Linux. I keep getting
"permission denied" messages after entering the path to the program. I
switched to the root directory and tried again, but got the same
result.I ran a very similar program earlier and it ran fine.
What am I doing wrong? The program is:
#!/usr/bin/python2.4
i=1
while i<10000:
print 'step 1',i
i+=1
raw_input()
print 'step 2'
Thank you.
Tom 8 3227
Tom Strickland wrote:
Hopefully this is a simple question. I've started to program in Python
after an absence of about a year, so I'm very rusty. I wrote a short
program and tried to run it using Python2.4 in Linux. I keep getting
"permission denied" messages after entering the path to the program. I
switched to the root directory and tried again, but got the same
result.I ran a very similar program earlier and it ran fine.
What am I doing wrong? The program is:
#!/usr/bin/python2.4
i=1
while i<10000:
print 'step 1',i
i+=1
raw_input()
print 'step 2'
Thank you.
Tom
Is your script executable?
hiaips wrote:
>
Tom Strickland wrote:
>Hopefully this is a simple question. I've started to program in Python after an absence of about a year, so I'm very rusty. I wrote a short program and tried to run it using Python2.4 in Linux. I keep getting "permission denied" messages after entering the path to the program. I switched to the root directory and tried again, but got the same result.I ran a very similar program earlier and it ran fine.
What am I doing wrong? The program is:
#!/usr/bin/python2.4 i=1 while i<10000: print 'step 1',i i+=1 raw_input() print 'step 2'
Thank you.
Tom
Is your script executable?
That's the problem I had when I wrote my first Python script. I wrote it
using vi, and vi doesn't save files with the executable flag set. A simple
'chmod 755 script.py' fixed that right up.
Then, to execute the file from from the shell prompt, I had to create a
'bin' directory in my home folder, cuz I didn't want to litter
my /usr/local/bin folder with useless Python scripts. (Useless because I
wrote them to learn the language and for no other practical purpose.) Of
course, I had to uncomment a line or two in my .bashrc file too.
Hey, what do I know? I'm as new to this as virgins are to... Well, you get
the idea. :-p
--
--
There are several things that I will never be:
* I will never be attracted to females.
* I will never enjoy the company of others.
Exactly how these realities bode for my enemy, is not of my concern.
In message <cP****************@read2.cgocable.net>, AlbaClause wrote:
Then, to execute the file from from the shell prompt, I had to create a
'bin' directory in my home folder, cuz I didn't want to litter
my /usr/local/bin folder with useless Python scripts.
Executable files can be kept anywhere, you don't need a special directory
for them.
Lawrence D'Oliveiro wrote:
In message <cP****************@read2.cgocable.net>, AlbaClause wrote:
>Then, to execute the file from from the shell prompt, I had to create a 'bin' directory in my home folder, cuz I didn't want to litter my /usr/local/bin folder with useless Python scripts.
Executable files can be kept anywhere, you don't need a special directory
for them.
Yes, I know, but if you want to just enter the filename at the shell prompt,
the file has to be somewhere that it can be found. Otherwise you get the
dreaded "command not found" error. Unless I'm doing something wrong?
--
--
There are several things that I will never be:
* I will never be attracted to females.
* I will never enjoy the company of others.
Exactly how these realities bode for my enemy, is not of my concern.
AlbaClause schrieb:
Lawrence D'Oliveiro wrote:
>>In message <cP****************@read2.cgocable.net>, AlbaClause wrote:
>>>Then, to execute the file from from the shell prompt, I had to create a 'bin' directory in my home folder, cuz I didn't want to litter my /usr/local/bin folder with useless Python scripts.
Executable files can be kept anywhere, you don't need a special directory for them.
Yes, I know, but if you want to just enter the filename at the shell prompt,
the file has to be somewhere that it can be found. Otherwise you get the
dreaded "command not found" error. Unless I'm doing something wrong?
In the most cases, PATH is preconfigured to include "." (. is the
current directory as .. is the parent one). You can use
../yourpythonscript in this case.
Another possibility is using `python script.py` to let the python
interpreter do the work directly.
The most "advanced" way would be expanding PATH with
/home/youraccount/python/learning (use PATH=$PATH:/path/here..).
Choose the one you're most comfortable with. :-)
Sincerely,
Stargaming
--
Stargaming <st********@gmail.comwrites:
In the most cases, PATH is preconfigured to include "." (. is the current
directory as .. is the parent one). You can use ./yourpythonscript in this
case.
I most cases on Unix boxes it isn't configured to include ".". This is so for
safety reasons (somebody might replace some command with a tampered binary or
a script and capture information that they shouldn't have access to...).
The solution of creating a directory and adding it to PATH is the best one,
IMHO. Having a "~/bin" is also common for Linux and some distributions of it
already ship with it in /etc/skel and in the PATH, so just put a link there or
copy your scripts there.
The most "advanced" way would be expanding PATH with
/home/youraccount/python/learning (use PATH=$PATH:/path/here..).
Yes. This is the best.
Choose the one you're most comfortable with. :-)
;-) And think about security as well.
--
Jorge Godoy <jg****@gmail.com>
On Sun, 20 Aug 2006 10:35:31 -0300, Jorge Godoy <jg****@gmail.comwrote:
Stargaming <st********@gmail.comwrites:
>In the most cases, PATH is preconfigured to include "." (. is the current directory as .. is the parent one).
I most cases on Unix boxes it isn't configured to include ".".
Indeed -- but "Stargaming" might have missed a negation somewhere, because
he went on to say
[rearranged from the above]
>You can use ./yourpythonscript in this case.
which is precisely what you /don't/ need to type if you have placed . in
your $PATH.
The solution of creating a directory and adding it to PATH is the best one,
IMHO. Having a "~/bin" is also common for Linux and some distributions of it
already ship with it in /etc/skel and in the PATH, so just put a link there or
copy your scripts there.
>The most "advanced" way would be expanding PATH with /home/youraccount/python/learning (use PATH=$PATH:/path/here..).
Yes. This is the best.
I wouldn't want random scripts under development ending up in my $PATH, not
even my own.
When you're just playing with/developing scripts, it's better to execute
them by path (./foo.py etc). When you think they work and you have a
long-term use for them, you install them globally, or copy, move or link
them into your ~/bin/.
/Jorgen
--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn!
Jorge Godoy wrote:
;-) And think about security as well.
I.e. put '.' in the end of your PATH, never in the beginning! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Klunk |
last post by:
Hi,
last week I moved the folder of my Intranet application to
another disk of the same server.
After this change all the ASP page return this error:
Microsoft VBScript runtime error...
|
by: Jon Montana |
last post by:
CDONTS was working well until I installed Exchange 2000. I thought it might
be a relay problem, but I allowed the server IP address to relay.
Thanks for anything you can offer.
here's the...
|
by: Mark E. Hamilton |
last post by:
Sorry, I probably should have re-stated the problem:
We're using Python 2.3.5 on AIX 5.2, and get the follow error messages
from some of our code. I haven't yet tracked down exactly where it's...
|
by: Florian G. Pflug |
last post by:
Hi
I installed a postgres-application (which was developed on debian
woody) on red hat 9 today, using the postgres 7.3 rpms from redhad.
One of my the triggers uses the pg_settings table (more...
|
by: Taishi |
last post by:
New user of SQL
Everything is on the same machine
My error is close to the bottom
After reading it today, I can see there is a problem with 2 dbases
'PUBS' and 'Master'
There are also some...
|
by: stephen |
last post by:
Hi,
I am getting an error while trying to create an excel file.
"Description: The application attempted to perform an operation not allowed
by the security policy. To grant this application the...
|
by: debug03 |
last post by:
I am executing a DTS package on a Windows 2000 sp4 server running SQL Server 2000 and IBM DB2 V7 client. The DTS package source data(SQL Server) is selected from SQL server table and inserts data to...
|
by: private.anders |
last post by:
Hi David!
Really need assistance since I have been struggling with a problem
long time now.
I am running a web application on a Win 2003 Std (Active Directory).
Everything works fine. I have...
|
by: private.anders |
last post by:
Really need your assistance since I have been struggling with a
problem long time now.
I am running a web application on a Win 2003 Std (Active Directory).
Everything works fine. I have...
|
by: xzzy |
last post by:
I have a v1.1 web app that works on my local computer. However, running it
at the host computer, the following breaks:
when a viewer selects a different country, the State dropdown should...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
| |