Best way to set global environment variables?

What is the best way to set global (i.e. for all users of the computer, ideally all shells as well) environment variables under Leopard?
I know that they can be set via ~/.bashrc, ~/.profile or in my case ~/.zshrc files in the terminal on a per user basis.
Also, they can be set for GUI apps as well via ~/.MacOSX/environment.plist on a per user basis.
http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Artic les/EnvironmentVars.html
The path can apparently be set globally by adding files to /etc/paths.d/*
http://blog.plotdevice.org/2008/04/global-path-in-mac-os-x-leopard/
Is there a way to set environment variables globally so that they are accessible to all users and all programs including nonstandard shells like zsh?
My inclination is to set them in /etc/rc.common but that seems like it might be a bad idea. I'd prefer something more like the /etc/paths.d/* solution that only involves adding files, not modifying existing ones. They should be less likely to be overwritten in a system update later.

They may be less likely to be overwritten than you fear. A lot of things depend on modifications to the system scripts like /etc/profile. Although I'd expect these to be broken by an upgrade to Leopard, for example, they have survived all Tiger upgrades on my machine. You could always have them source scripts in /usr/local, say, so that the work involved in reconfiguring them if they are overwritten is minimal. (Or you could just install your versions in /usr/local and make the system scripts symlinks to those versions - if anything is overwritten, it would be the symlink rather than the file itself. An automated start up script could even check and recreate the symlink if necessary.)
- cfr

Similar Messages

  • Best practice for setting an environment variable used during NW AS startup

    We have installed some code which is running in both the ABAP and JAVA environment, and some functionality of this code is determined by the setting of operating system environment variables. We have therefore changed the .sapenv_<host>.csh and .sapenv_<host>.sh scripts found in the <sid>adm user home directory. This works, but we are wondering what happens when SAP is upgraded, and if these custom shell script changes to the .sh and .csh scripts will be overwritten during such an upgrade. Is there a better way to set environment variables so they can be used by the SAP server software when it has been started from <sid>adm user ?

    Hi,
    Thankyou. I was concerned that if I did that there might be a case where the .profile is not used, e.g. when a non-interactive process is started I was not sure if .profile is used.
    What do you mean with non-interactive?
    If you login to your machine as sidadm the profile is invoked using one of the files you meant. So when you start your Engine the Environment is property set. If another process is spawned or forked from a running process it inherits / uses the same Environment.
    Also, on one of my servers I have a .profile a .login and also a .cshrc file. Do I need to update all of these ?
    the .profile is used by bash and ksh
    The .cshrc is used by csh and it is included via source on every Shell Startup if not invoked with the -f Flag
    the .login is also used by csh and it is included via source from the .cshrc
    So if you want to support all shells you should update the .profile (bash and ksh) and one of .cshrc or .login for csh or tcsh
    In my /etc/passwd the <sid>adm user is configured with /bin/csh shell, so I think this means my .cshrc will be used and not the .profile ? Is this correct ?
    Yes correct, as described above!
    Hope this helps
    Cheers

  • [Solved] systemd-user-session: Best way to pass global ENV vars?

    Hey guys,
    So when using the [email protected] from the user-session-units what's the best / cleanest way to set global environment variables for that systemd --user instance (and thus, all programs spawned from it)?
    What I'm talking about is /etc/profile and $HOME/.profile.
    For example, I usally configure my XDG_CONFIG_HOME and XDG_CACHE_HOME in my ~/.profile. But since systemd --user is being started by systemd --session none of these environment variables are loaded.
    The solution I've come up is to change the ExecStart in the [email protected] file to something like this:
    ExecStart=/usr/bin/sh -c "source /etc/profile; source $HOME/.config/bash/environment; exec /usr/lib/systemd/systemd --user"
    I know I could use the `EnvironmentFile` option to load the environment variables from a file, but it's not as flexable as a bash script.
    Am I thinking about this problem wrong? Is there a more "systemd --user"-y way of solving the problem?
    Last edited by EvanPurkhiser (2013-08-12 03:02:48)

    I've more or less solved this using my own user-session units. I still don't know if my method would really be considered the proper way or not though.
    Last edited by EvanPurkhiser (2013-08-12 03:02:19)

  • Global Environment Variables?

    What is the best way to set global (i.e. for all users of the computer) environment variables under Leopard?
    I know that they can be set via ~/.bashrc, ~/.profile or in my case ~/.zshrc files in the terminal on a per user basis.
    Also, they can be set for GUI apps as well via ~/.MacOSX/environment.plist on a per user basis.
    http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Artic les/EnvironmentVars.html
    The path can apparently be set globally by adding files to /etc/paths.d/*
    http://blog.plotdevice.org/2008/04/global-path-in-mac-os-x-leopard/
    Is there a way to set environment variables globally so that they are accessible to all users and all programs including nonstandard shells like zsh?
    My inclination is to set them in /etc/rc.common but that seems like it might be a bad idea. I'd prefer something more like the /etc/paths.d/* solution that only involves adding files, not modifying existing ones. They should be less likely to be overwritten in a system update later.

    Thanks for the reminder. It has been reposted here: http://discussions.apple.com/thread.jspa?threadID=1513246

  • Any way to set global variables except EAS console?

    Hi pros,
    I am searching for a way to set global variables (used by business rules) automatically.
    I got several variables which should change each month. I know the rule to set them.
    However, I cannot find any way to set them through scripting or something else.
    I tried to research EAS repository. The one that I found relevant is HBRVariables table.
    I cannot find any tool can help this.
    Any one knows how?
    Appreciated......
    Casp Huang

    Yes you can use substitution variables in business rules and they are widely used, it is relatively easy to automate the changing of values for subtitution values.
    You can also put a sub var into the default value for a global variable in business rules.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Best way to set up partitions on 250GB external drive

    Hi all,
    I've decided to go with an Iomega eGo 250-GB FireWire portable drive to back up my iBook's hard disk (30 GB) plus to store my photos and maybe hold a bootable copy of OS9.
    This is my first time using an external drive, so I don't really know how to go about setting things up.
    What would be the best way to set up the partitions on the external drive?
    1) I know I should create a 30GB partition for the iBook backup, but what about for the remaining volume? Is it best to leave it as a single large 200GB partition, or split it into two 100GB chunks? Other than the clone of my iBook, I'll mainly be storing photos (at the moment no more than around 10-12GB).
    2) I don't yet have a huge iTunes collection, but if I later want to store iTunes music that doesn't fit on my internal drive, is it fine to put it in the same partition as the photos, or would it be preferable to create a separate partition?
    3) If I want to install OS9 on the drive, how much space should I allot to it? Would this enable me to run legacy apps on my iBook?
    4) Does it matter how I name the partitions (i.e. should the name for my iBook back-up be the same as the original volume or should it be different?)
    5) As I still don't know exactly what I need, If today I decide to create only 30GB partition to backup the iBook, can I later partition the remaining space without having to start all over again?
    6) Also, the drive came out of the box with Mac OS Extended format. Is this the best format or is there another that would be better?
    Thanks for any advice
    Message was edited by: Lutetia

    1) I know I should create a 30GB partition for the iBook backup, but what about for the remaining volume? Is it best to leave it as a single large 200GB partition, or split it into two 100GB chunks? Other than the clone of my iBook, I'll mainly be storing photos (at the moment no more than around 10-12GB).
    2) I don't yet have a huge iTunes collection, but if I later want to store iTunes music that doesn't fit on my internal drive, is it fine to put it in the same partition as the photos, or would it be preferable to create a separate partition?
    The answer to both question is that it's completely up to you. Partitioning or not partitioning won't affect operation significantly.
    3) If I want to install OS9 on the drive, how much space should I allot to it? Would this enable me to run legacy apps on my iBook?
    The iBook G4 can not boot from OS 9 so you would only be able to run OS 9 in the "classic" environment.
    4) Does it matter how I name the partitions (i.e. should the name for my iBook back-up be the same as the original volume or should it be different?)
    No
    5) As I still don't know exactly what I need, If today I decide to create only 30GB partition to backup the iBook, can I later partition the remaining space without having to start all over again?
    There are a few tools which promise the ability to change the partitioning without destroying the data on the drive. But you should never do this without making a backup of the data on the drive. Data loss can easily happen and in a big way.
    6) Also, the drive came out of the box with Mac OS Extended format. Is this the best format or is there another that would be better?
    That is the best format.

  • What is the best way to define this missing variable?????

    I think I am almost there with this question, thanks for working with me on this: trying to make buttons go target cue points in video
    I get this error code:
    ReferenceError: Error #1065: Variable seek_btn is not defined.
    import fl.video.*;
    // Video component instance name
    var flvControl:FLVPlayback = display;
    var flvSource:String = "lou.flv";
    // Set video
    flvControl.source = flvSource;
    // Add seek functionality to the button
    function seekHandler(event:MouseEvent):void
       flvControl.seekToNavCuePoint("lou1")
    seek_btn.addEventListener(MouseEvent.CLICK, seekHandler);
    seek_btn1.cuePointName = new String();
    seek_btn1.cuePointName = "lou1";
    seek_btn1.addEventListener(MouseEvent.CLICK, onButtonPress);
    seek_btn2.cuePointName = new String();
    seek_btn2.cuePointName = "lou2";
    seek_btn2.addEventListener(MouseEvent.CLICK, onButtonPress);
    // onButtonPress function
    function onButtonPress(evt:MouseEvent):void {
         flvControl.seekToNavCuePoint(evt.target.cuePointName);

    Definitely.... you are trying to assign a listener to something that does not exist
    seek_btn.addEventListener(MouseEvent.CLICK, seekHandler);
    If you do not have a seek_btn, the best way to define the missing variable is to create the seek_btn object.  If you don't plan to, then rather than define it, get rid of any code that uses it.

  • Is there any way to get windows environment variables like %USERNAME% with javascript?

    is there any way to get windows environment variables like %USERNAME% with javascript using Adobe 10 pro?

    There is a fair amount of Acrobat JavaScript and Acrobat knowledge need to sort all of this out.
    The identity object holds a lot of sedative information. First, upon installation of Acrobat, only the login name is available in the identity object and the end user of the application needs to complete the "Name", "email" and "Organization Name" in the application's preferences. These are the only fields that are available to Acrobat JavaScript identity object as corporation, email, loginName, and name.
    Using the instructions in The Acrobat JavaScript Console (Your best friend for developing Acrobat JavaScript) you can run the following script in the JS console to see the items of the identity object:
    for(i in identity) {
    console.println(i +": " + identity[i]);
    and the following will appear in the console:
    loginName: georgeK
    name: George Kaiser
    corporation: Example
    email: [email protected]
    true
    The documentation states you need to use a trusted function to access this data, but you can access it at startup of Acrobat/Reader and add the properties of the identity object to an array:
    // application variable to hold the properties of the identity object
    var MyIdentity = new Array();
    // loop through the properties of the identity object
    for (i in identity) {
    // place each property of the identity object into an element of the same name in the Identity array
    MyIdentity[i] = identity[i];
    console.println(i +": " + MyIdentity[i])
    You access the items with:
    var loginUser = MyIdentity[loginName];  // get the loginName property
    In the user application level JavaScript file. See Acrobat Help / User JavaScript Changes for 10.1.1 (Acrobat | Reader) for the location of the application level folder you need to use.
    I would change the name of the array used in this post so an untrusted user cannot get to your data. Some of this data can be used in hacking into a user's system.

  • Setting new environment variable on Linux

    {noformat}I need to set new environment variable on my linux machine from inside my code. I am using csh and the command works fine from command line:
    setenv IFConfigLocation4 /home/username/myfile.xml
    But when i try the same thing from Java code it does not seem to have any effect. here is my code:
    import java.util.*;
    import java.io.*;
    public class CDE_parser_methods{
    public static String fileParse(String inFile, String parserName, String outFile, String CMConfig_locale)
    String parsed = "SUCCESSFUL";
    System.out.println("Parsing file..." + "\nParser name: " + parserName +"\nInput file name: " + inFile + "\nOutput file name: " + outFile + "\nCMConfig file is: " + CMConfig_locale);
    System.out.println("Current Java version: " + System.getProperty("java.version"));
    try
              String cmd[]={"/bin/csh", "-c", "setenv IFConfigLocation4 " + CMConfig_locale};
              Process proc = Runtime.getRuntime().exec(cmd);
              int exitVal= proc.waitFor();
              System.out.println("Value of setenv command is: " + exitVal);
              String cmd2[]={"/bin/csh", "-c", "env"};
              Process proc2 = Runtime.getRuntime().exec(cmd2);
              InputStream instr = proc2.getInputStream();
              InputStreamReader inread = new InputStreamReader(instr);
              BufferedReader buf = new BufferedReader(inread);
              String line=null;
              while((line=buf.readLine()) != null)
                   System.out.println(line);
              int exitVal2= proc2.waitFor();
              }catch(CMException cme){
                   System.out.println("Issue when trying to executing parse command, details: " + cme.getMessage());
                   System.out.println("Description of the issue is: " + cme.getDescription());
                   parsed = "FAILURE: " + cme.getDescription();
              }catch(Exception e){
                   System.out.println("Uncought exception, details: " + e.getMessage());
                   parsed = "FAILURE: " + e.getMessage();
         return parsed;
    public static void main(String[] args) {
         String results=CDE_parser_methods.fileParse("/opt/itemfield/ServiceDB/Project2/Mapping_for_Account_Number_Structure_ITS_Input_File.xls","MappingforAccountNumberStructure","/opt/itemfield/ServiceDB/Project2/test_ws_44.xml","/home/rvenishe/CMConfig.xml");
         System.out.println("Result of fileParse call is: " + results);
         }The out put of my env command does NOT contain system variable "IFConfigLocation4". Any ideas? {noformat}

    Environment variables and their values set from within a user process has their scope and lifetime limited to the process and its subprocesses. See java.lang.ProcessBuilder class and its API documentation for setting env for a subprocess that will be started by a ProcessBuilder instance. Even in the C programming we have the same limitation for the environment.
    Since they are not globally set, system command like env or Java method like System.getenv() can't see them.

  • What is the best way to set up iTunes on our home network so all family members have access to all of our itunes library, even music we don't have on the cloud?

    I have five different people using 10 different apple devices on one itunes account in our family.  We have had trouble sharing.  What is the best way to set up itunes on our home network?  We have purchased music that sits on icloud, but we also have music we have imported from our previous cd library.  Our itunes program keeps crashing and dumping everyone's playlists.  So far we have all been using just the one desktop computer to sync to because we can't figure out how to share the same librarly and playlists on multiple computers in our home so devices can be synced at any location as well as playlists and purchases be made. 

    What is the best way to set up itunes on our home network? 
    One iTunes library per person.  One iTunes account per person.
    If people wish to share songs, they can make copies.
    When the inevitable day comes when the kids get older, you will not have to come back here and post asking how all that stuff can get separated!

  • What Is The Best Way To Set Up Kids iTouch To My iTunes?

    I have an iTouch set up with my iTunes music, movies and apps, but now I gave my kids each an iTouch.
    What is the best way to set up there account, should it be a unique account for each of them or should I put them under my account?
    They will be using my same iMac when they sync or update there iTouch, so will they need to log in under their name every time?
    Not sure what is the best way to set this up, they are both minors, i.e. no credit card.
    Thanks

    Better just your account for multiple devices. The only drawback is that the music will have to managed manually.
    Connect one of the iPods to your computer then launch iTunes. You should see the iPod under Devices on the left side of the iTunes window. Double click then you can name each iPod to keep them separate but only syncs to your iTunes account.
    Without knowing your Apple ID user name and password they would not be able to make purchases ergo no downloads you aren't aware of.
    How to use multiple iPods, iPads, or iPhones with one computer
    The kids are minors.. if they are under 13 years of age, according to Apple, they can't have their own accounts regardless.
    http://www.apple.com/legal/itunes/us/terms.html#GIFTS

  • What is the best way of setting up Family Sharing?

    I just bought my son an iPad Mini and I am trying to decide on what is the best way of setting it up for him. The one thing I do know is that I do NOT want all the content that is my iPhone 6 to pop up on his iPad Mini. I want his iPad to be used for his games and educational stuff and his own music. I don't mind setting up a family photo album and share photos with the family. So is the Family Sharing option the best way of doing this based on what I just mentioned? Do I set him up with his own Apple ID? If so will everything still be based off my account so he won't have to create his own iTunes Library?
    I always use iTunes gift cards to purchase music and content. Will I be able to continue to use them even if I want to put some new content on his iPad and not my iPhone? Do I enter in his Apple ID info. Can you restrict certain family members to just certain things for example you only want to share photos with one person whereas you might want to share your music with another family member?
    Any suggestions on the best way of setting this up would great!
    Thanks!

    Hi DVX100Shooter,
    Congratulations on getting your son a new iPad, I am sure he will enjoy it. 
    Family Sharing is one way of managing both purchases and content between members of a related group of people. Each member must have their own Apple ID. You can choose what music you wish to share with the family from your own account. See this article -
    OS X Yosemite: Share purchases with your family
    In particular the section titled Hide a purchase from other family members
    The music library on your son's iPad is separate from yours, but under Family Sharing you agree to pay for all purchases made through the iTunes store. If you wish to control what is purchased you can set up the Ask to Buy option for any family member under adult age in your location. See this article for details -
    Request and make purchases with Ask to Buy - Apple Support
    Gift cards may not be used for billing of purchases under family sharing, with the exception that a family member may use gift cards to purchase their own content. See this article for information about Family Sharing billing policies -
    Family purchases and payments - Apple Support
    The shared family photo album is available to all family members.
    Family Sharing - Apple Support
    Thanks for using Apple Support Communities.
    Best,
    Brett L 

  • Our granddaughter has a ipod. She's getting a iphone and a mini idpad.  what is the best way to set them up. Does she need a new apple id and password or would she use the same one she has for her ipod

    our granddaughter has a ipod. She's getting a iphone and a mini idpad.  what is the best way to set them up. Does she need a new apple id and password or would she use the same one she has for her ipod

    Just use the same one on all devices.

  • What is the best way to set up iTunes to deal with a massive media library?

    I have a really big media library...probably 7k-10k digital photos, close to 1,000 ripped CDs, and over 600 ripped DVDs, all stored on 1.5TB external hard disks in a 4-drive enclosure.
    Due to a recent technical glitch, I find myself installing a new drive and moving the current library. My question is, what is the best way to set up iTunes' settings to deal with a media library that is both external to the Mac on which it runs, and spans multiple physical hard disk units?
    I generally like the idea of iTunes organizing my library for me (i.e. keeping everything in Media Type>Artist>Album folders via the "Automatically Add to iTunes" folder), but I'm not sure how that's going to work spanning multiple drives.
    I just figure since I'm basically starting over with my iTunes installation, maybe there's a better way to do it.
    Thanks in advance for any advice you can offer.

    You can set them up as a software RAID using Disk Utility.
    It'll simply be one large disk for all intents and purposes.

  • What's the best way to set up new imac for logic etc?

    In brief:
    Getting new imac (27", 3.4 i7, 8-16GB ram, 1TB HD). Will be using it mainly to run Logic Studio (loads of plugins) and Final Cut Express. I also have 2 external Hard drives one 500G one 1TB.
    The last imac I bought was my first and just went ahead and threw everything at it not really knowing where things should go. This time I want to set things up correctly.
    Basically, with what I've got, what is the best way to set things up. I.e where do I put logic files, samples, BFD2, Amplitube etc. Where do I put videos for use in FCE. Storing projects and backups for use with Time Machine.
    Also noticed the new imac will only have 1 firewire port. I will need to plug in the Hard drives (daisy chained), camera and RME Fireface 800. Was thinking of getting a Thunderbolt Hard drive but they are expensive and hard to find.
    Would really appreciate any help before I get the new machine and start messing things up again.
    Thanks.

    Adding to babowa, enable the system firewall in System Preferences>Security>Firewall tab. Click Advanced and check Stealth Mode.
    Lion is a pretty steady and secure operating system, and as there really aren't MANY Mac viruses, there ARE viruses out there still. OS X is pretty good about letting you know if you do accidently download a virus, and it will help you throw it away if it detects one, such as the MACDefender virus. OS X has built in security features such as sandboxing that doesn't allow viruses in as easily as a Windows PC. As for hackers, as long as you have the firewall enabled and a secure password (for your computer and email accounts), then you should be fine.
    It's the user that lets the virus in, not the computer (unless there's some untold serious vulnerability in OS X, which is highly unlikely). Keep your apps up to date, don't download pirated software, and be street smart on the internet. Don't download things or visit websites that you don't think are real. Safari includes a Phishing feature that automatically detects known phishing sites, protecting you from that big problem. Keep your passwords secure and you should be fine.
    There are antivirus solutions out there, one notable one available in the AppStore is Intego's VirusBarrier (free and plus versions), if you feel you still need one.
    I wouldn't worry about it. Windows users who switch to Mac are always asking these questions.
    Here's some good reading as well
    http://www.apple.com/macosx/what-is/security.html
    Enjoy OS X Lion

Maybe you are looking for

  • Random() with Objective C

    I need an absolute number generated from 1 to 4. my random number picked 1-4 in C# picknumber = random.Next(1,5); documentation on random() for Objective C > DOES NOT TELL YOU HOW TO USE IT it just lectures you on what it is, but not how its used. It

  • Two file adapter questions

    First, can someone post a URL for detailed file adapter documentation? Second, I'm a little confused how to use the file adapter in the case where I'm writing out a message whose schema is contained in one of the wsdl files instead of in an xsd file.

  • Lock records command

    Hi all, I have a scenario where i have to lock the lookup table records for editing. So that other users cannot edit the record. I am processing the lock record command for records which are not locked by other session (LOCK_BY_OTHER_SESSION). Lets s

  • Call BAPI to Create Invoice During PGI(VL01N) via BADI

    Hi, Requirement: During PGI (VL01N), we have implemented a BADI (IF_EX_DELIVERY_PUBLISH) in method (PUBLISH_AFTER_SAVE) to call BAPI (BAPI_BILLINGDOC_CREATEMULTIPLE) to create invoice simultaneously with the PGI. In DEV box, the call BAPI is working

  • Saving Song Data in Excel

    I know that I used to be able to save a copy of my song list in Excel so that I can print it if people wanted to see my list. I have downloaded the new version of iTunes and now when I try to export my library it does not open correctly in Excel. I h