home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tkibin04.zip / README.pycmd < prev    next >
Text File  |  1999-05-28  |  2KB  |  39 lines

  1.  
  2. This is just a little hack to get around the deficiencies of OS/2's
  3. "extproc" command for running python programs.  OS/2's "extproc" command is
  4. similar to the UNIX "#!" hack.  It allows you to execute programs written in
  5. any scripting language by specifying the interpreter in the first line. For
  6. example, if you wanted to run a python program by just entering it's name on
  7. the command line, you could call the program "myprogram.cmd" and put:
  8.  
  9.     extproc python -x
  10.     
  11. in the first line of the file.  OS/2's CMD shell sees this when it tries to
  12. run the file as a batch file and then invokes the "python -x" command with
  13. the file name and all of the arguments as additional parameters.  The "-x"
  14. option tells the python interpreter to ignore the first line of the file.
  15.  
  16. The problem with this is, unlike the UNIX "#!" hack, the "extproc" command
  17. doesn't give the interpreter the full path name of the file.  This means
  18. that you can only execute your script from the current directory!  Since
  19. that seemed very limiting to me, I wrote this program, which automatically
  20. includes the "-x" option and searches for the script in the current
  21. directory and then in the PATH.  It then calls Py_Main() with the complete
  22. path of the script so that it can be run from anywhere.
  23.  
  24. So now, you can just use the following start line:
  25.  
  26.     extproc pycmd
  27.  
  28. to run your scripts from wherever you like.
  29.  
  30. But wait, there's more!  Since I've also done a half-ass port of Tkinter to
  31. OS/2, pycmd also comes in a PM enabled flavor called "pmpycmd".  To run your
  32. Python Tkinter scripts, just put:
  33.  
  34.     extproc pmpycmd
  35.  
  36. in the first line (assuming that you have installed OS/2 Tkinter, of course)
  37. and you're all set.  For this to be any cooler, you'd have to be running
  38. UNIX.
  39.