473,394 Members | 1,810 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,394 software developers and data experts.

Too long of a process to save .py scripts

jimpy
7
Greetings,
Using Ubuntu 7.10 and Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2

I am presently going through the "A Byte Of Python" tutorial.

When I copy the little .py scripts and save them, I find they must be in the /usr/bin directory.

But I cannot directly save them to that location. I have to save them to my Documents folder, then execute a "gksudo nautilus" command to access /usr/bin. Then click and drag the file into the /usr/bin directory.

Very cumbersoe, but I don't know any other way to get them in the right location.

Obviously, I am relatively new to Ubuntu, and absolutely new to Pythoon.

Thank you
Mar 18 '08 #1
5 1397
Laharl
849 Expert 512MB
You do not need to save python scripts in /usr/bin. Make the first line of the script (every script) #!/usr/bin/python if you want to use ./ to run it after marking it executable with chmod. Otherwise, you can use python to run the script with the command 'python foo.py'.
Mar 18 '08 #2
jimpy
7
Thank you for the reply, Lahari -
I do make the first line #! /usr/bin/python.
And I do make the scripts executable.
You last answer,
"Otherwise you can use python to run the script with the command python foo.py",
went over my head.
With the script residing in /usr/bin, I can open a terminal and type the just the script name, and it will execute.
My problem is getting the scripts into place without so much effort.
I know I am missing something here, but I just don't know what it is.
Mar 18 '08 #3
micmast
144 100+
I think you want to execute it like this:

$> myprogram.py

right?

if so you need to add the directory to your working path

$> PATH=/my/home/dir/with/python/scripts/:$PATH

Don't forget the $PATH at the end!!!!


The easy way:

just add ./ in front of the script

$> ./myprogram.py
Mar 18 '08 #4
jimpy
7
Ah yes ... that is good. Problem solved. Sometimes I can be very very dense.

Many thanks for the replies. It's really appreciated.

And now, onward and upward!
Mar 18 '08 #5
Laharl
849 Expert 512MB
The 'python foo.py' is telling python to run the file foo.py. If you had a different file, say myfile.py, the command would be python myfile.py. This is more secure than adding . to your path. If you just type 'python' in, you'd get an interactive Python shell you can use to try things out that can be quite useful sometimes.
Mar 18 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Doug | last post by:
I have a script that does a huge database update, which takes a long time. However, the host I am running on (and I suspect most hosts) are running in "safe mode." This means I cannot change the...
3
by: Bob Bedford | last post by:
Some of my code has a long process, and my ISP limits the scripts to 30 seconds. Now, I must absolutely create a file with some string (simply a number and an email), then process any line with...
15
by: Ville Vainio | last post by:
Pythonic Nirvana - towards a true Object Oriented Environment ============================================================= IPython (by Francois Pinard) recently (next release - changes are...
5
by: =?Utf-8?B?Z215ZXJz?= | last post by:
Hello, I am attempting to start a cmd.exe process and pass several .vbs scripts (with additional parameters) and then read the output from the scripts and make "notes" in a DataTable (the...
5
by: David Mathog | last post by:
I'm looking at a program which stores perl scripts in an array. Each script is stored as a single entry in that array, and the whole set of them live in a single header file (escaped out the wazoo...
4
by: cuneyt.barutcu | last post by:
The following ALTER takes about 2 hours in my environment. total number of records is about 2.8 million. IS this typical? Is there a way to speed up this process. BEGIN TRANSACTION SET...
4
by: J. Frank Parnell | last post by:
Hi there, I have a list of links which point to e.g. thescript.php?album=somePictures1 thescript.php?album=somePictures2 This list is about 3000 links. Each album may have 500 or more...
1
by: walterbyrd | last post by:
I understand that Python has them, but PHP doesn't. I think that is because mod_php is built into apache, but mod_python is not usually in apache. If mod_python was built into apache, would...
4
by: commander_coder | last post by:
Hello, I write a lot of CGI scripts, in Python of course. Now I need to convert some to long-running processes. I'm having trouble finding resources about the best practices to do that. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...

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.