On Thu, Nov 6, 2008 at 16:42, Wagner, David --- Senior Programmer Analyst --- WGO <[EMAIL PROTECTED]> wrote: > I need an environment variable from my .profile on Solaris and having > troubles getting at it. I have a Perl script which executes fine outside of > cron and now am trying to do via cron. I wanted to stay away from a shell > script and was wondering what is the easiest way to get my .profile loaded, > so the Perl script can access the needed variable. > > I have tried with errors the following: > > 25 12 * * 4 . $HOME/.profile ; /d/src/pl600.pl dp51 > > and > > 25 12 * * 4 . $HOME/.profile && /d/src/pl600.pl dp51 > > I get the error: > sh: -o: bad option(s) > > I believe it should not be that hard to do, but I only have really > enough knowledge to dangerous and know when to ask for help. > > Thoughts, examples, site(s) where can pickup info to assist in this??? > > If you have any questions and/or problems, please let me know. > Thanks. snip
I normally resort to a shell script calling my Perl script, but there lots of options: 1. coding the script such that it doesn't need an environment (e.g. full paths on executables called) 2. setting the necessary environment variables in %ENV manually 3. parsing your .profile and setting the environment variables in %ENV All three have potential drawbacks: 1. this is not always possible 2. this is not always possible and if there needs to be a change you need to modify every file you done this in 3. this is the best of the options, but it is not always enough and can be hard to do right In the end, the safest thing to do is only call shell scripts from your scheduler. In fact, I often create one shell script that takes as an argument the name of another executable file to run. This gives me common entry point for all scheduled jobs so I can do logging and any other work that is common to all jobs (such as setting the environment). -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/