Archive

Archive for the ‘Linux’ Category

Makefile woes: PATH variable

September 9th, 2009 No comments

Was just writing a Makefile and ran into kind of a silly snag. The Makefile wasn’t finding any of the standard Unix commands (rm, rsync, …). What happened was I set the variable “PATH” to a value that I wanted to use on my script, totally forgetting the special significance of it.

Categories: Linux Tags:

crontab shell

August 10th, 2009 1 comment

I wrote a Python script that I want to run every five minutes through a crontab. The script ran fine and linked with my local libraries until I ran it through the crontab and it couldn’t find my local libraries. After a bit of thought, I realized that the crontab was not running through the same shell environment as I expected it to. Apparently the shell is set in /etc/crontab file and there it was set to bash. That in turn was calling the wrong version of Python, and that was why my local Python scripts weren’t being found.

There are four different ways around this:
1) Modify /etc/crontab to hit the right shell; in my case (first line modified):
/etc/crontab

SHELL=/bin/tcsh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

crontab -e

*/5 * * * * python /my/script.py

2) Add the shell value to the top of the custom crontab (crontab -e); in my case:

SHELL=/bin/tcsh

*/5 * * * * python /my/script.py

3) Run the actual command through the tcsh as so:

*/5 * * * * tcsh -c "python /my/script.py"

4) Directly request the right version of Python:

*/5 * * * * /tools/bin/python /my/script.py
Categories: Linux, Python Tags:

Append to PYTHONPATH in Ubuntu

August 13th, 2008 2 comments

Not sure how other distros have this setup, but I know this works with Ubuntu…

First off, to view your PYTHONPATH. Load the python shell, by just running “python” from your favorite prompt. Then the following.


>>> import sys
>>> for line in sys.path: print line

Modifying it is as simple as adding a path file (such as “myproject.pth”) to this folder:

/usr/local/lib/pythonx.y/site-packages

Then within the file “myproject.pth” put the path to the folder of interest.

Important asside:
Although this is useful to know, the reason I ended up figuring this out was to add the path of my project so that my own project could access a certain folder within the project. What I really missed was just adding an __init__.py within the folder I added to my project, which is why I couldn’t treat the folder as a module… Arg!

Categories: Linux, Python, Ubuntu Tags:

Installing Django from SVN and setting up django-registration (on Ubuntu)

March 14th, 2008 No comments

Go to the shell and navigate to a directory that you want to leave the Django codebase. then enter the following code to check out the current codebase from Django:
svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk

Next you will need to make a symbolic link to the Django codebase:

sudo ln -s `pwd`/django-trunk/django/ /usr/lib/python2.5/site-packages/django

Link to django-admin, which is used to create Django projects:

sudo ln -s `pwd`/django-trunk/django/bin/django-admin.py /usr/local/bin

Make sure not to use regular apostrophes around pwd or else you could run into an error with your libraries.  I was getting this error (since the mapping was going to the wrong place)
Traceback (most recent call last):

File "manage.py", line 2, in <module>
from django.core.management import execute_manager
ImportError: No module named django.core.management

Django registration

svn checkout http://django-registration.googlecode.com/svn/trunk/registration/ registration/
sudo ln -s `pwd`/registration /usr/lib/python2.5/site-packages/registration

Categories: Django, Linux, MSSQL, Ubuntu Tags:

Configure router on network

May 20th, 2007 1 comment

I was having a problem configuring my router and all that was needed was a refresh of the DHCP settings on the router.

On my router I had to logon to my router by going to 192.168.1.1 and then just refreshing the DHCP.

Categories: Linux Tags:

Setting up pentium core 2 duo on Ubuntu

May 16th, 2007 No comments

I spent a lot of time trying to diagnose this problem. What would happen is that when I would login to Ubuntu I would get the following message “CPU frequency scaling unsupported.”

There are two things that need to be done. First you have to make sure SpeedStepping is set. The way to activate this is to go into your setup when the computer starts up and check your processor settings.

The next thing you have to do is get a kernel that supports this chip. The standard 386 kernel that comes with the Ubuntu (Dapper/Edgy/Feisty) does not support it. You need to go into Synaptic and download the generic kernel.

By the way I spent hours trying to compile my own kernel since I didn’t know that prebuilt kernels existed as a package. Apparently the Ubuntu people don’t want us compiling our own kernels and have made it as difficult as possible. I got as far as I willing to go with the kernel compiling process. I got the kernel setup in the GRUB and loaded it, but the computer would stop somewhere while loading. There probably is no reason to compile your own kernel at this point. I don’t think having extra things turned on in the kernel will even make a difference at this point.

Categories: Linux Tags: