Running scripts within scripts 
Author Message
 Running scripts within scripts

**** Post for FREE via your newsreader at post.usenet.com ****

Is it posible for a python to call a second without importing a module? I
don't really want to call os.system and have to include paths. Just call a
second script in the same directory as the parent one.

Thanks.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 *** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
                      http://www.*-*-*.com/
Unlimited Download - 19 Seperate Servers - 90,000 groups - Uncensored
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



Sun, 19 Dec 2004 06:24:29 GMT  
 Running scripts within scripts

Quote:

> Is it posible for a python to call a second without importing a module? I
> don't really want to call os.system and have to include paths. Just call a
> second script in the same directory as the parent one.

You could say

  os.system("./other-script.py")

which doesn't need to include any paths.



Sun, 19 Dec 2004 07:11:31 GMT  
 Running scripts within scripts

Quote:


>>Is it posible for a python to call a second without importing a module? I
>>don't really want to call os.system and have to include paths. Just call a
>>second script in the same directory as the parent one.

> You could say

>   os.system("./other-script.py")

> which doesn't need to include any paths.

Seems like this is exactly what execfile was written for.  It does
require a file object to work on though but it's not hard to get one

        try:
                # use open() to get a file object.  In python 2.2 and
                # later, use file() instead.
                fin = open('other-script.py')
        except IOError:
                # print witty error message here

        # execute the code in the specified file
        execfile(fin)

There are more advanced versions of execfile that take a globals and
locals maps.  See the python documentation at http://www.python.org for
instructions on how to use them.

Hope this helps,
Brandon



Sun, 19 Dec 2004 11:23:19 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Running a TK script using wish80.exe within a tcl script

2. Access to Script Name Within Awk Script

3. Calling scripts from within scripts, is this possible?

4. Expect scripts within expect scripts

5. Problem with consecutive running of a gawk script within a loop

6. Run awk from within sed script?

7. Running Awk scripts from within VB

8. how to debug matlab script running within labview

9. run a script within...

10. Running an external command from within a Python script

11. running a tcl script from within a sub folder

12. Run a Perl script within TCL

 

 
Powered by phpBB® Forum Software