Re: [SLUG] Scripting question

From: Paul M Foster (paulf@quillandmouse.com)
Date: Thu Sep 05 2002 - 21:39:42 EDT


On Thu, Sep 05, 2002 at 07:59:17PM -0400, Smitty wrote:

> On Thursday 05 September 2002 17:02, you wrote:
> > Joe O wrote:
> >
> > If portability is a concern, I would go with Python. It works the same
> > way regardless of the shell (even non-Bourne shells). It even works on
> > Windows!
> >
> >
> > import os
> > for i in range(0,5):
> > os.system("echo hello world")
> > os.system("echo run some other command")
>
> I am assuming you would prepend the above script with py at the prompt to
> call python and the os.system=linux in this case.
> Smitty
>

Linux isn't as "suffix sensitive" as DOS and Windows; suffixes don't
necessarily cause the shell to invoke the proper interpreter. In the
python world, I believe you would prepend the following to the script
above (someone correct me if I'm wrong):

#!/usr/bin/env python

There are other ways to do this, but it seems like I've seen the above
used the most.

Paul



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:02:11 EDT