Professional Web Applications Themes

How to load environment ? - PERL Beginners

Hi, I have a bash file that loads some variables needed by some perl scripts, I need the environment to be available at any moment, so i included the line that loads the environment in my .bash_profile, but when the perl scripts runs from the crontab, the environment is not available. So i use another bash script to load the environment and run the perl script from one line in the crontab, the content of the load and run script is this: ----------------------------------------------------------------------------------- !/bin/sh .. ~max/tmp/g_amb.sh # <-- This Loads the environment. /home/max/tmp/l_amb.pl # <-- This uses the environment loaded. ...

  1. #1

    Default How to load environment ?


    Hi,

    I have a bash file that loads some variables needed by some perl scripts, I
    need the environment to be available at any moment, so i included the line
    that loads the environment in my .bash_profile, but when the perl scripts
    runs from the crontab, the environment is not available.

    So i use another bash script to load the environment and run the perl script
    from one line in the crontab, the content of the load and run script is this:

    -----------------------------------------------------------------------------------
    !/bin/sh
    .. ~max/tmp/g_amb.sh # <-- This Loads the environment.
    /home/max/tmp/l_amb.pl # <-- This uses the environment loaded.
    -----------------------------------------------------------------------------------

    How could i load the environment from the perl script without using the load
    and run script ?

    Some perl or bash scripts are going to use the environment variables and i
    dont want to define the variables on every script,

    this is a sample content of the script that loads the enviroment:

    -----------------------------------------------------------------------------------
    #!/bin/sh

    PVAR="Var P"
    XVAR="Var X"

    export PVAR XVAR
    -----------------------------------------------------------------------------------

    thanks

    saludos
    max

    Max Guest

  2. #2

    Default Re: How to load environment ?

    On Fri, May 14, 2004 at 07:59:40PM -0500, max wrote:
     

    Check out Shell::Source. http://search.cpan.org/dist/Shell-Source/

    --
    Paul Johnson - net
    http://www.pjcj.net
    Paul Guest

  3. #3

    Default Re: How to load environment ?

    On Fri, May 14, 2004 at 07:59:40PM -0500, max wrote:
    [...] 


    Max,

    It sounds like you have a perfectly good solution. Quite honestly, I
    would stick with it. Here's why:

    First off, you've got two factors working together here:

    1) Multiple Perl scripts must be able to see these variables.

    2) At the time the Perl scripts are run, the environment is not
    normally available.

    #1 says that you need to centralize the variables somewhere so that
    multiple scripts can load them up.

    #2 says that you are going to need to take some explicit action to
    instantiate the variables.



    If you don't like that, then something like the following might work
    (not tested):

    -------------- File MyEnv.pm in INC
    package MyEnv;
    use Env;

    $ENV{PVAR} = 'p var';
    $ENV{XVAR} = 'x var';
    -------------- End


    -------------- Begin script file:
    #!/usr/bin/perl

    use MyEnv;
    -------------- End

    David Guest

Similar Threads

  1. Administering CF settings in load-balanced environment
    By Ishmealm in forum Coldfusion Server Administration
    Replies: 1
    Last Post: July 25th, 10:34 PM
  2. DPAPI in a Load Balanced Environment
    By Ron Ifferte in forum ASP.NET Security
    Replies: 2
    Last Post: February 28th, 01:56 AM
  3. Replies: 1
    Last Post: August 6th, 04:32 PM
  4. Any free load generator for Solaris 9 in Java environment?
    By EKL in forum Linux / Unix Administration
    Replies: 0
    Last Post: August 6th, 01:06 PM
  5. load environment
    By Enzo in forum PERL Miscellaneous
    Replies: 1
    Last Post: July 9th, 11:02 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139