Re: [SLUG] Scripting question

From: Ronan Heffernan (ronan@iotcorp.com)
Date: Thu Sep 05 2002 - 21:22:43 EDT


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

You can:
     * paste this text into the interactive Python interpreter
     * type "python filename"
     * chmod 755 the file and add a line at the beginning of the file:
             #!/usr/bin/env python

In Windows, appending .py to the filename should cause the shell to
kick-off the Python interpreter if the file is 'launched'. In Linux,
adding .py will have no impact on how the file is handled (the
execute-bit makes it a script, and the first line tells the shell how to
execute the script).

--ronan



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