os.spawnl error

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

    #1

    os.spawnl error

    Hello,

    Does someone already had ths problem ?
    [color=blue][color=green][color=darkred]
    >>> os.spawnl(os.P_ NOWAIT,'c:\wind ows\notepad.exe ')[/color][/color][/color]
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "C:\Python24\li b\os.py", line 565, in spawnl
    return spawnv(mode, file, args)
    OSError: [Errno 22] Invalid argument

    Regards

    Salvatore

  • Larry Bates

    #2
    Re: os.spawnl error

    The backslashes in your path are being interpreted
    as escape characters (e.g. \n is a newline).

    Try instead:

    os.spawnl(os.P_ NOWAIT,r'c:\win dows\notepad.ex e')

    or

    os.spawnl(os.P_ NOWAIT,'c:\\win dows\\notepad.e xe')

    -Larry Bates


    Salvatore wrote:[color=blue]
    > Hello,
    >
    > Does someone already had ths problem ?
    >
    >[color=green][color=darkred]
    >>>>os.spawnl(o s.P_NOWAIT,'c:\ windows\notepad .exe')[/color][/color]
    >
    > Traceback (most recent call last):
    > File "<stdin>", line 1, in ?
    > File "C:\Python24\li b\os.py", line 565, in spawnl
    > return spawnv(mode, file, args)
    > OSError: [Errno 22] Invalid argument
    >
    > Regards
    >
    > Salvatore
    >[/color]

    Comment

    • Larry Bates

      #3
      Re: os.spawnl error

      The backslashes in your path are being interpreted
      as escape characters (e.g. \n is a newline).

      Try instead:

      os.spawnl(os.P_ NOWAIT,r'c:\win dows\notepad.ex e')

      or

      os.spawnl(os.P_ NOWAIT,'c:\\win dows\\notepad.e xe')

      -Larry Bates


      Salvatore wrote:[color=blue]
      > Hello,
      >
      > Does someone already had ths problem ?
      >
      >[color=green][color=darkred]
      >>>>os.spawnl(o s.P_NOWAIT,'c:\ windows\notepad .exe')[/color][/color]
      >
      > Traceback (most recent call last):
      > File "<stdin>", line 1, in ?
      > File "C:\Python24\li b\os.py", line 565, in spawnl
      > return spawnv(mode, file, args)
      > OSError: [Errno 22] Invalid argument
      >
      > Regards
      >
      > Salvatore
      >[/color]

      Comment

      • Fredrik Lundh

        #4
        Re: os.spawnl error

        Salvatore wrote:
        [color=blue]
        > Does someone already had ths problem ?
        >[color=green][color=darkred]
        >>>> os.spawnl(os.P_ NOWAIT,'c:\wind ows\notepad.exe ')[/color][/color]
        > Traceback (most recent call last):
        > File "<stdin>", line 1, in ?
        > File "C:\Python24\li b\os.py", line 565, in spawnl
        > return spawnv(mode, file, args)
        > OSError: [Errno 22] Invalid argument[/color]

        that string doesn't contain what you think:
        [color=blue][color=green][color=darkred]
        >>> print "c:\windows\not epad.exe"[/color][/color][/color]
        c:\windows
        otepad.exe

        you can use "raw" string literals to get around this:
        [color=blue][color=green][color=darkred]
        >>> os.spawnl(os.P_ NOWAIT, r'c:\windows\no tepad.exe')[/color][/color][/color]

        more here:



        </F>



        Comment

        • Fredrik Lundh

          #5
          Re: os.spawnl error

          Salvatore wrote:
          [color=blue]
          > Does someone already had ths problem ?
          >[color=green][color=darkred]
          >>>> os.spawnl(os.P_ NOWAIT,'c:\wind ows\notepad.exe ')[/color][/color]
          > Traceback (most recent call last):
          > File "<stdin>", line 1, in ?
          > File "C:\Python24\li b\os.py", line 565, in spawnl
          > return spawnv(mode, file, args)
          > OSError: [Errno 22] Invalid argument[/color]

          that string doesn't contain what you think:
          [color=blue][color=green][color=darkred]
          >>> print "c:\windows\not epad.exe"[/color][/color][/color]
          c:\windows
          otepad.exe

          you can use "raw" string literals to get around this:
          [color=blue][color=green][color=darkred]
          >>> os.spawnl(os.P_ NOWAIT, r'c:\windows\no tepad.exe')[/color][/color][/color]

          more here:



          </F>



          Comment

          • utabintarbo

            #6
            Re: os.spawnl error

            I have found the judicious use of os.path.normpat h(path) to be quite
            useful as well.

            Bob

            Comment

            • utabintarbo

              #7
              Re: os.spawnl error

              I have found the judicious use of os.path.normpat h(path) to be quite
              useful as well.

              Bob

              Comment

              Working...