python script question

Erik Max Francis max at
Mon Oct 21 22:46:20 CEST 2002

Ken wrote:

> Hi all, just like to ask if python CGI script can be mix with python
> Shell
> script?
> I.e. if:
> file1 is CGI (#!/usr/local/bin/python)
> and file2 is shell script (#!/bin/sh)
> can I have "import file2" inside file1 and use the functions inside
> file2?

No.  You want os.system or some variant.

The import statement in Python is _only_ for importing Python modules.

> Also, does the shell script have *.py extension?

If it did and tried to import it you'd get some interesting syntax

 Erik Max Francis / max at /
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ I want a martini that could be declared a disaster area.
\__/ Capt. Benjamin "Hawkeye" Pierce
    Alcyone Systems' Daily Planet /
 A new, virtual planet, every day.

More information about the Python-list mailing list