> -----Original Message----- > From: Chas. Owens [mailto:[EMAIL PROTECTED] > Sent: Saturday, November 08, 2008 10:14 AM > To: Wagner, David --- Senior Programmer Analyst --- WGO > Cc: Perl Beginners > Subject: Re: Cron environment for execution of Perl script > > 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). > > -- Understood, but now I need two items to update: shell and Perl. I have one variable I need and I don't need anything else, but by having that one variable I can switch between Windows, Solars and Linux with what I am doing without having to make changes to the script. Since Windows uses the extention to determine what program to execute and the location for the perl executable is pretty constant between Linux and Unix, this makes things pretty easy to handle. I have my own poller(s) which handle getting data from IBM(MVS), Solaris and Windows and they have been running with no problems for a little over five years, but I needed a cron job to make things a little bit easier and was having all kinds of problems.
I do appreciate the feedback and will take a look at what is happening. Thanks much. Wags ;) David R. Wagner Senior Programmer Analyst FedEx Freight 1.408.323.4225x2224 TEL 1.408.323.4449 FAX http://fedex.com/us > 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/