passing vars to py scipts in cron jobs

Noud Aldenhoven jwaixs at gmail.com
Wed Aug 8 04:10:39 EDT 2007


On 8/7/07, Will Maier <willmaier at ml1.net> wrote:
>
> On Tue, Aug 07, 2007 at 05:45:46PM -0400, brad wrote:
> > What's the proper way to call a py script and pass in variables
> > while doing cron jobs? I can run the scripts fine from idle,
> > python, etc using raw_input() to prompt users. The scripts have
> > classes with methods that need arguments.
>
> This is commonly done with either sys.argv (a list of arguments
> passed when invoking the script) or os.environ (a dictionary of
> environment variables and values). Use either to instantiate your
> classes or run functions.



You might also want to look at the function getopt <
http://docs.python.org/lib/module-getopt.html>.
It's used to parse the variables in sys.argv which makes it (in my opinion)
more user friendly.

-- 
<:3 )~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070808/4470964e/attachment.html>


More information about the Python-list mailing list