[Tutor] Path?

Adam Bark adam.jtm30 at gmail.com
Wed Jul 14 16:01:30 CEST 2010


On 14 July 2010 02:53, Jim Byrnes <jf_byrnes at comcast.net> wrote:

> Adam Bark wrote:
>
> <snipped some old stuff>
>
>
>  If I use the terminal to start the program it has no problem using the
>>>>> file.  There are multiple files in multiple directories so I was
>>>>> looking
>>>>> for
>>>>> a way to just double click them and have them run.  If it turns out
>>>>> that
>>>>> I
>>>>> must make changes to or for each of the files it will be easier to just
>>>>> keep
>>>>> using the terminal.  I've only been using Ubuntu for a few months so I
>>>>> was
>>>>> surprised that the program could not see a file that is in the same
>>>>> directory.
>>>>>
>>>>> Regards,  Jim
>>>>>
>>>>>
>>>>
>>>> The problem is ubuntu doesn't run the script from the directory it's in
>>>> so
>>>> it's looking for wxPython.jpg somewhere else.
>>>>
>>>>
>>>>  OK, I mistakenly thought that double-clicking on file in Nautilus would
>>> take care of the path info.
>>>
>>> In my reply above I also mentioned that I tried by dropping it on a
>>> Launcher on the top panel and that the command the launcher uses is
>>> usr/bin/python2.6.  Is there a way that the command can be changed so
>>> that
>>> it will look in the same directory the python script is in for any file
>>> it
>>> needs?
>>>
>>> Thanks,  Jim
>>>
>>
>>
>> Not sure if you got my previous email but you could try writing the bash
>> script I posted (with the $1 line to get the path) and setting that as
>> your
>> launcher, I think it should work.
>>
>> Let me know if you didn't get it or it doesn't work.
>>
>> HTH,
>> Adam.
>>
>>
> I got it, got sidetracked and then forgot to look at it again.  Thanks for
> reminding me.  Your idea works, but with one little downside.  The
> directories I am working with are chapters in a book.  So as I move from
> chapter to chapter I will need to change the bash script, but this seems to
> be less typing than using the terminal.
>
>
> Thanks,  Jim
>

Ok cool, glad it works. It might be possible to get the path so you don't
have to set it each time, try this:

 #!/bin/bash

IFS="/"
path=($1)
cd $(path[0:#path[*]])
python $1


# Warning, I'm not exactly a competent bash programmer so this may not work
:-p

Let me know if you need a hand to fix it,

HTH,
Adam.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100714/6be7c7a5/attachment-0001.html>


More information about the Tutor mailing list