#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    11
    Rep Power
    0

    Make phyton file executable


    Hello everyone,

    Can someone tell me how I can run a file named system_test.py with only system.test and not ./system_test.py.

    Thank you in advanced.

    Take care,
    I.
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    I'm not really sure what you mean, could you give me a little more info?

    If you want to execute another Python program from within Python you could check out exec_file(path)..

    Or, if u want to run .test files with Python under windows you can select a program from a list if you double click on file, on *nix i dont think it matters which extension the file has as long as the shebang (#!/usr/bin/env python etc.) points to the right place!?

    Have fun,
    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    11
    Rep Power
    0
    Thank you for your post.

    I'm using Linux and I have created a system_test.py file.
    What I need is to call this file by doing:

    system.test -a -f file

    where -a -f file are arguments.

    I'm currently using ./system_test.py -a -f file to run the script but I need to get rid of the ./system_test.py and call the script with system_test instead.

    Is this possible?


    Take care,

    I.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    133
    Rep Power
    12
    Remove the .py and place the file in your path.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    9
    Rep Power
    0
    Another method would be to create a symbolic link in something like /usr/bin that points to the file. That way, you don't have to copy your python code all over the place or have a massive PATH environment variable.

    Suppose you have a python script called /usr/share/systemtest/system_test.py

    Just do the following:

    Code:
    ln -s /usr/share/systemtest/system_test.py /usr/bin/systemtest
    Last edited by red_over_blue; October 19th, 2003 at 03:18 PM.

IMN logo majestic logo threadwatch logo seochat tools logo