How to get a script's directory

classic Classic list List threaded Threaded
4 messages Options
ZeWaren / Erwan Martin ZeWaren / Erwan Martin
Reply | Threaded
Open this post in threaded view
|

How to get a script's directory

Hi,
I'm writing scilab scripts (.sci files) on a daily basic.
Theses scripts need to access some files around them, typically graphs.

How can I get the location of the script in a variable, so that I can do
something like this?:
    cpath=get_script_path();
    graph=load_graph(cpath+'some_graph.graph');
I need to be able to execute my scripts on different computers in
different places on different operating systems.
I know that I can get scilab's current working directory using pwd() and
change it using cd(...), but this doesn't solve my problem.

Thanks for any response.

--
Erwan MARTIN / ZeWaren
----------------------------------------------------
IRL:  ARPEJ Lgt 453G, 1360 rte de Ste Anne,
      29280 PLOUZANE, FRANCE
tel:  +33(0)9.51.66.58.34  cell: +33(0)6.32.01.15.01
80:   http://zewaren.net       25:  [hidden email]
5222: [hidden email]        1863:  [hidden email]
----------------------------------------------------



Calixte.Denizet Calixte.Denizet
Reply | Threaded
Open this post in threaded view
|

Re: How to get a script's directory

Hi,

> How can I get the location of the script in a variable, so that I can do
> something like this?:
>     cpath=get_script_path();
>     graph=load_graph(cpath+'some_graph.graph');

Maybe cpath=get_absolute_file_path('myscript.sci') could be useful.

Calixte



Collette yann-2 Collette yann-2
Reply | Threaded
Open this post in threaded view
|

Re: How to get a script's directory

In reply to this post by ZeWaren / Erwan Martin
ZeWaren / Erwan Martin a écrit :

> Hi,
> I'm writing scilab scripts (.sci files) on a daily basic.
> Theses scripts need to access some files around them, typically graphs.
>
> How can I get the location of the script in a variable, so that I can
> do something like this?:
>    cpath=get_script_path();
>    graph=load_graph(cpath+'some_graph.graph');
> I need to be able to execute my scripts on different computers in
> different places on different operating systems.
> I know that I can get scilab's current working directory using pwd()
> and change it using cd(...), but this doesn't solve my problem.
>
> Thanks for any response.
>
Try path = get_absolute_file_path(('your_script_name.sci');

YC


ZeWaren / Erwan Martin ZeWaren / Erwan Martin
Reply | Threaded
Open this post in threaded view
|

Re: How to get a script's directory

In reply to this post by Calixte.Denizet
This is what I was looking for.

Thank you.

This function should be added to the "See Also" section of the command
"pwd". That way I would have found it on my own without having to bother
you on this list.

Calixte Denizet wrote:

> Hi,
>
>  
>> How can I get the location of the script in a variable, so that I can do
>> something like this?:
>>     cpath=get_script_path();
>>     graph=load_graph(cpath+'some_graph.graph');
>>    
>
> Maybe cpath=get_absolute_file_path('myscript.sci') could be useful.
>
> Calixte
>
>  
--
Erwan MARTIN / ZeWaren
----------------------------------------------------
IRL:  ARPEJ Lgt 453G, 1360 rte de Ste Anne,
      29280 PLOUZANE, FRANCE
tel:  +33(0)9.51.66.58.34  cell: +33(0)6.32.01.15.01
80:   http://zewaren.net       25:  [hidden email]
5222: [hidden email]        1863:  [hidden email]
----------------------------------------------------