Path question

R C cjvijf at gmail.com
Mon Oct 19 05:47:26 UTC 2020


Hi Phil,

I was a little late reading the posts, but when it works it works.


just in case you were curious:

it takes '3' lines, but can wrie it as a one liner;

The first command line option, index 0 is the "command" it is executed 
with;  argv[0] it always exists

in python: |sys.argv[0]|

|then, get the "directory name" from it; the basename  in python: 
|||os.path.||basename|(/path/)|

|for example (basename('/my/path/to/script.py") would be "|||/my/path/to"||

|then change to that directory:  chdir;  in python : |||os.chdir()||

||
||

||so at the beginning of your python script a line like:||

||||os.chdir(||||||||||os.path.||basename|(//||||||||||/|sys.argv[0]|/)|);||||

||||
||||

||||should do that trick
||||

||||
||||

||||
||||

||||just a thought.||||

||||
||||

||||Ron||||

||||
||||

||||
||||

|
|



On 10/18/20 11:26 PM, Phil wrote:
> On 19/10/20 1:39 pm, R C wrote:
>> might be a little late, but just saw this.
>>
>>
>> Why don't you set the working/current directory in your script?
>
> Thanks Ron for you suggestion. After a good night's sleep I had solved 
> the problem with a simple bash script.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20201018/eb2a00da/attachment.html>


More information about the ubuntu-users mailing list