Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Windows Environment Variable from the local system when running Stata via RemoteApp


From   Jean-François Morazzani <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: Windows Environment Variable from the local system when running Stata via RemoteApp
Date   Tue, 16 Apr 2013 09:10:58 +0000

In fact we are already using relative path within our scripts, except for that my_project" directory that needs to be absolute, as every user has different path. So I wanted to use a Environment Variable to replace the "cd /path/to/my_project" instruction to something like :
Local user_path : env USERPROJECTPATH
Cd "`userpath'"

Thanks again for your help, the issue comes down to the use of RemoteApp. I will think of something and will post my findings. For the mean time we will have to do the first "cd" to go to the user's working directory.

And also thank you William for the tips, even if it is not the solution to my problem, it's a best practice that everyone should always follow. 

Regards,

JFM

-----Message d'origine-----
De : [email protected] [mailto:[email protected]] De la part de Phil Schumm
Envoyé : lundi 15 avril 2013 18:05
À : [email protected]
Objet : Re: st: Windows Environment Variable from the local system when running Stata via RemoteApp

On Apr 15, 2013, at 10:33 AM, Jean-François Morazzani wrote:
> Thanks Phil for your reply, but unfortunately it does not fix my issue.
> 
> The thing is that I want to use a "local/global" that will be set to some users' specific folder on their local machine. So everyone could copy the script on their machine and test/use the scripts without having to open it and modify the local path.
> 
> For example my script will do the following:
> 
> local ScriptsFolder "c:\Temp\Stata\"
> use "`ScriptsFolder'\data\SomeData.dta", clear do 
> "`ScriptsFolder'\SomeScript.do"
> ...
> 
> The thing is that I cannot pass arguments to Stata has I'm using it through RemoteApp (therefore I'm calling Stata using a .rdp shortcut on my deskptop).
> 
> Thanks anyway.
> I guess I will have to find another solution, like replacing the value of the local ScriptsFolder manually or automatically via a custom script.


I may still not understand exactly what you are trying to do (or the constraints within which you are working, since I'm not familiar with RemoteApp), but in general, if you are writing code that you want to be portable (e.g., across machines, between users, etc.), you should be using relative paths instead of absolute paths.  So, for example, you might place all of the code in a directory called my_project, and then structure all path references so that they are relative to the root of that directory.  You can then distribute that directory any way you choose, and users simply need to fire up Stata and type

    cd /path/to/my_project
    do relative/path/to/do-file

If your project relies on data, you can either include copies of the data file(s) in the my_project directory, or simply have your users create one or more symlinks within my_project to the location of the data file(s).


-- Phil


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index