running non-python progs from python

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

    #16
    Re: running non-python progs from python


    "Fedor" <fedor@mailandn ews.com> wrote in message
    news:3fd66012$0 $113$3a628fcd@r eader2.nntp.hcc net.nl...[color=blue]
    >
    > "Spiffy" <spiffy@worldne t.att.net> wrote in message
    > news:2fsBb.4239 99$0v4.20388116 @bgtnsc04-news.ops.worldn et.att.net...[color=green]
    > >
    > > "Diez B. Roggisch" <deets_noospaam @web.de> wrote in message
    > > news:br5hu8$em2 $01$1@news.t-online.com...[color=darkred]
    > > > > Here is the code used to call it from Python:
    > > > > import os
    > > > > filename = "C:\Python22\Ca nyon.mid"
    > > > > os.system("C:\P ython22\playb.e xe%s"%filename)
    > > > > ...this causes a dos box to appear which promptly hangs and does[/color]
    > > nothing,[color=darkred]
    > > > > at which time Python stops responding. Vartiations on this will[/color][/color][/color]
    cause[color=blue][color=green]
    > > the[color=darkred]
    > > > > dos box to appear with the message "Bad command or file name".
    > > > >
    > > >
    > > > Looks like there is a space missing -
    > > >
    > > > os.system("C:\P ython22\playb.e xe %s"%filename)
    > > > ^
    > > >
    > > > Diez
    > > >[/color]
    > > There is no space missing. That is the name of the file on my comp.
    > >
    > >[/color]
    >
    > The ^ points right after exe. (use fixed fonts to see). The command you[/color]
    are[color=blue]
    > executing is:
    >
    > C:\Python22\pla yb.exeC:\Python 22\Canyon.mid
    >
    > There needs to be a space between exe and the second C:
    >
    > Hope it helps.
    >
    >[/color]
    I have tried your suggestion and put a space after the .exe...the result is
    the same as before...a dos box appears and does nothing and python crashes
    (stops responding).


    Comment

    • Dennis Lee Bieber

      #17
      Re: running non-python progs from python

      Spiffy fed this fish to the penguins on Tuesday 09 December 2003 14:06
      pm:

      [color=blue]
      > C:\Python22>pla yb Canyon.mid
      >
      > Here is the code used to call it from Python:
      > import os
      > filename = "C:\Python22\Ca nyon.mid"
      > os.system("C:\P ython22\playb.e xe%s"%filename)[/color]

      If that is the true statement you are using then it is NOT the same as
      the command line shown above... THERE'S NO SPACE BETWEEN PROGRAM and
      ARGUMENT!

      You are trying to run a file named:

      C:\Python22\pla yb.exeC:\Python 22\Canyon.mid


      --[color=blue]
      > =============== =============== =============== =============== == <
      > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
      > wulfraed@dm.net | Bestiaria Support Staff <
      > =============== =============== =============== =============== == <
      > Bestiaria Home Page: http://www.beastie.dm.net/ <
      > Home Page: http://www.dm.net/~wulfraed/ <[/color]

      Comment

      • Fredrik Lundh

        #18
        Re: running non-python progs from python

        Spiffy wrote:
        [color=blue][color=green]
        > > that indicates that it's supposed to work, don't you think?[/color]
        >
        > IT COULD HAVE BEEN A MISPRINT, DON'T YOU THINK?[/color]

        sure. if multiple independent sources say the same thing, your
        first thought should be that they're all wrong.
        [color=blue][color=green][color=darkred]
        > > > Both the .exe and the .mid file are in the python path and the spelling
        > > > been checked.[/color]
        > >
        > > you mean sys.path?[/color]
        >
        > IF I HAD MEANT sys.path, I WOULD HAVE SAID sys.path, DON'T YOU THINK?[/color]

        the python path is stored in the sys.path variable. why did you
        say python path if you didn't mean it?
        [color=blue]
        > I DO NOT THINK THE PROBLEM IS IN HOW I USED THE FUNCTION
        > NOR WHAT I EXPECTED FROM IT.[/color]

        no, your problems are obviously elsewhere. good luck with your
        programming career.

        </F>




        Comment

        • Spiffy

          #19
          Re: running non-python progs from python


          "Fredrik Lundh" <fredrik@python ware.com> wrote in message
          news:mailman.26 .1071059811.930 7.python-list@python.org ...[color=blue]
          > Spiffy wrote:
          >[color=green][color=darkred]
          > > > that indicates that it's supposed to work, don't you think?[/color]
          > >
          > > IT COULD HAVE BEEN A MISPRINT, DON'T YOU THINK?[/color]
          >
          > sure. if multiple independent sources say the same thing, your
          > first thought should be that they're all wrong.
          >[color=green][color=darkred]
          > > > > Both the .exe and the .mid file are in the python path and the[/color][/color][/color]
          spelling[color=blue][color=green][color=darkred]
          > > > > been checked.
          > > >
          > > > you mean sys.path?[/color]
          > >
          > > IF I HAD MEANT sys.path, I WOULD HAVE SAID sys.path, DON'T YOU THINK?[/color]
          >
          > the python path is stored in the sys.path variable. why did you
          > say python path if you didn't mean it?
          >[color=green]
          > > I DO NOT THINK THE PROBLEM IS IN HOW I USED THE FUNCTION
          > > NOR WHAT I EXPECTED FROM IT.[/color]
          >
          > no, your problems are obviously elsewhere. good luck with your
          > programming career.
          >
          > </F>[/color]

          It's interesting to me that, although you provided no help or answers to me,
          you are convinced that you did. In fact, it is clear from your first
          response that your intention has been to amuse yourself by spouting attitude
          at me. Hope you had a good time. Meanwhile, Fredo has provided a nice answer
          that WORKS... along with an explanation of why my code didn't work. He was
          HELPFUL and didn't seem to have the need to belittle me for not being a
          professional Python Master. You remind me of one of these teens on IRC who
          have no other pleasure in life but to sit around and boot people out of
          their precious little chat rooms. I imagine if this was IRC, you would have
          booted me at the first post.


          Comment

          • Dennis Lee Bieber

            #20
            Re: running non-python progs from python

            Dennis Lee Bieber fed this fish to the penguins on Wednesday 10
            December 2003 00:31 am:

            Talking to myself, again...[color=blue]
            >
            >
            > Spiffy fed this fish to the penguins on Tuesday 09 December 2003 14:06
            > pm:
            >
            >[color=green]
            >> os.system("C:\P ython22\playb.e xe%s"%filename)[/color]
            >[/color]

            What result do you get with just:

            os.system("dir" )

            --[color=blue]
            > =============== =============== =============== =============== == <
            > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
            > wulfraed@dm.net | Bestiaria Support Staff <
            > =============== =============== =============== =============== == <
            > Bestiaria Home Page: http://www.beastie.dm.net/ <
            > Home Page: http://www.dm.net/~wulfraed/ <[/color]

            Comment

            • Fredrik Lundh

              #21
              Re: running non-python progs from python

              "Spiffy" wrote:
              [color=blue]
              > Meanwhile, Fredo has provided a nice answer that WORKS...
              > along with an explanation of why my code didn't work.[/color]

              for the benefit of others, maybe you could tell us why
              your code didn't work?

              </F>




              Comment

              • Mark

                #22
                Re: running non-python progs from python


                "Spiffy" <spiffy@worldne t.att.net> wrote in message
                news:IHrBb.1726 31$Ec1.6601048@ bgtnsc05-news.ops.worldn et.att.net...[color=blue]
                >
                > "Dennis Lee Bieber" <wlfraed@ix.net com.com> wrote in message
                > news:ef9ha1-6p3.ln1@beastie .ix.netcom.com. ..[color=green]
                > > Spiffy fed this fish to the penguins on Tuesday 09 December 2003 00:38
                > > am:
                > >[color=darkred]
                > > > from the "Learning Python" book. When I run it, the dos command line
                > > > appears with the message 'Bad command or file name". Both the .exe and
                > > > the .mid file are in the python path and the spelling has been
                > > > checked. What I expected to happen was that the os.system call would
                > > > start the .exe and begin playing the .mid file. This does not happen.
                > > > This is what I meant when I said I haven't been able to get this to
                > > > work.
                > > >[/color]
                > > So include (don't retype or paraphrase, use cut&paste) the[/color][/color]
                /exact/[color=blue][color=green]
                > > code which is failing, AND the exact command window output...
                > >
                > > Among other things, I don't think os.system() uses the /Python/[/color]
                > path[color=green]
                > > -- its the equivalent of opening a new command prompt and typing the
                > > command; so it is the OS search path that is used.
                > >
                > > Open a command window, and type the exact command you think you[/color]
                > are[color=green]
                > > using in os.system()
                > >
                > > --[color=darkred]
                > > >[/color][/color]
                > In the command window the call to the program with the name of the[/color]
                ..mid[color=blue]
                > file to be played works just fine. Here is what it looks like....exactly :
                > C:\Python22>pla yb Canyon.mid
                >
                > Here is the code used to call it from Python:
                > import os
                > filename = "C:\Python22\Ca nyon.mid"
                > os.system("C:\P ython22\playb.e xe%s"%filename)
                > ...this causes a dos box to appear which promptly hangs and does nothing,[/color]
                at[color=blue]
                > which time Python stops responding. Vartiations on this will cause the dos
                > box to appear with the message "Bad command or file name".
                >[/color]

                Try:
                import.os
                os.system(r"C:\ Python22\playb. exe %s"%filename)

                or:
                import os
                os.system("C:\\ Python22\\playb .exe %s"%filename)

                -Mark
                [color=blue]
                >
                > =============== =============== =============== =============== == <[color=green][color=darkred]
                > > > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
                > > > wulfraed@dm.net | Bestiaria Support Staff <
                > > > =============== =============== =============== =============== == <
                > > > Bestiaria Home Page: http://www.beastie.dm.net/ <
                > > > Home Page: http://www.dm.net/~wulfraed/ <[/color]
                > >[/color]
                >
                >[/color]


                Comment

                • Spiffy

                  #23
                  Re: running non-python progs from python

                  [color=blue]
                  > or:
                  > import os
                  > os.system("C:\\ Python22\\playb .exe %s"%filename)
                  >[/color]

                  Thank you. Fedor had emailed me yesterday with this solution and a nice
                  explanation. Thanks to all who tried to help.


                  Comment

                  • Cameron Laird

                    #24
                    Re: running non-python progs from python

                    In article <6t5Cb.180692$E c1.6826191@bgtn sc05-news.ops.worldn et.att.net>,
                    Spiffy <spiffy@worldne t.att.net> wrote:[color=blue]
                    >[color=green]
                    >> or:
                    >> import os
                    >> os.system("C:\\ Python22\\playb .exe %s"%filename)
                    >>[/color]
                    >
                    >Thank you. Fedor had emailed me yesterday with this solution and a nice
                    >explanation. Thanks to all who tried to help.
                    >
                    >[/color]

                    Did anyone ever disclose the solution publicly? This
                    case has me curious; os.system() misunderstandin gs
                    often arise, and I'd like to learn more about what can
                    go wrong.
                    --

                    Cameron Laird <claird@phaseit .net>
                    Business: http://www.Phaseit.net

                    Comment

                    Working...