Shell: run script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • leroybt.rm

    Shell: run script

    Can someone tell me how to run a script from a interactive shell

    I type the following:
    [color=blue][color=green][color=darkred]
    >>>python filename
    >>>python filename.py
    >>>run filename
    >>>run filename.py
    >>>/run filename
    >>>/run filename.py[/color][/color][/color]

    and in all cases I get errors. I can't believe I can not run
    a script from the shell.

    What am I doing wrong?????

    Help!!!!!!!!!


  • vincent wehren

    #2
    Re: Shell: run script

    "leroybt.rm " <leroybt@rocket mail.com> schrieb im Newsbeitrag
    news:mailman.11 14.1069872227.7 02.python-list@python.org ...
    | Can someone tell me how to run a script from a interactive shell
    |
    | I type the following:
    |
    | >>>python filename
    | >>>python filename.py
    | >>>run filename
    | >>>run filename.py
    | >>>/run filename
    | >>>/run filename.py


    You want to run a script from *inside the Python Interactive Shell*? Or do
    you want to run a Python script (*.py) as a program from any (other than the
    Python shell)? Or did you mix these two things up?


    Vincent Wehren







    | and in all cases I get errors. I can't believe I can not run
    | a script from the shell.
    |
    | What am I doing wrong?????
    |
    | Help!!!!!!!!!
    |
    |


    Comment

    • Logan

      #3
      Re: Shell: run script

      On Wed, 26 Nov 2003 18:40:05 +0000, leroybt.rm wrote:
      [color=blue]
      > Can someone tell me how to run a script from a interactive shell
      >
      > I type the following:
      >[color=green][color=darkred]
      >>>>python filename
      >>>>python filename.py
      >>>>run filename
      >>>>run filename.py
      >>>>/run filename
      >>>>/run filename.py[/color][/color]
      >
      > and in all cases I get errors. I can't believe I can not run
      > a script from the shell.[/color]

      Normally, you do not want to run your scripts from a Python shell,
      but from the bash etc. (Linux shells) or from a DOS console
      (Windows) etc. For this, you use:

      python <path_to_file >

      If you really want to run a script from the Python shell, the
      following will do:

      execfile("<path _to_file>")

      HTL, L.


      --
      mailto: logan@phreaker( NoSpam).net

      Comment

      • Wojtek Walczak

        #4
        Re: Shell: run script

        Dnia Wed, 26 Nov 2003 18:40:05 -0000, leroybt.rm napisa³(a):[color=blue]
        > Can someone tell me how to run a script from a interactive shell[/color]

        You mean interactive session? If yes, then do:

        import os
        os.system('/path/to/a/script')

        --
        [ Wojtek Walczak - gminick (at) underground.org .pl ]
        [ <http://gminick.linuxse curity.pl/> ]
        [ "...rozmait e zwroty, matowe od patyny dawnosci." ]

        Comment

        Working...