which command i should use to get write permission for file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nitinloml
    New Member
    • Mar 2007
    • 8

    which command i should use to get write permission for file

    cs = open(r"session1 .txt", "a+")
    cs.write(i)




    cs undefined, builtin open = <type 'file'>

    IOError: [Errno 13] Permission denied: 'session1.txt'
    args = (13, 'Permission denied')
    errno = 13
    filename = 'session1.txt'
    strerror = 'Permission denied'
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by nitinloml
    cs = open(r"session1 .txt", "a+")
    cs.write(i)




    cs undefined, builtin open = <type 'file'>

    IOError: [Errno 13] Permission denied: 'session1.txt'
    args = (13, 'Permission denied')
    errno = 13
    filename = 'session1.txt'
    strerror = 'Permission denied'
    "
    >>> help(open)
    Help on class file in module __builtin__:

    class file(object)
    | file(name[, mode[, buffering]]) -> file object
    |
    | Open a file. The mode can be 'r', 'w' or 'a' for reading (default),
    | writing or appending. The file will be created if it doesn't exist
    | when opened for writing or appending; it will be truncated when
    | opened for writing. Add a 'b' to the mode for binary files.
    | Add a '+' to the mode to allow simultaneous reading and writing.
    | If the buffering argument is given, 0 means unbuffered, 1 means line
    | buffered, and larger numbers specify the buffer size.
    | Add a 'U' to mode to open the file for input with universal newline
    | support. Any line ending in the input file will be seen as a '\n'
    | in Python. Also, a file so opened gains the attribute 'newlines';
    | the value for this attribute is one of None (no newline read yet),
    | '\r', '\n', '\r\n' or a tuple containing all the newline types seen.
    |
    | 'U' cannot be combined with 'w' or '+' mode.
    |
    | Note: open() is an alias for file()."

    That last part is very pertainate to you situation.

    Comment

    • ghostdog74
      Recognized Expert Contributor
      • Apr 2006
      • 511

      #3
      Originally posted by nitinloml
      cs = open(r"session1 .txt", "a+")
      cs.write(i)




      cs undefined, builtin open = <type 'file'>

      IOError: [Errno 13] Permission denied: 'session1.txt'
      args = (13, 'Permission denied')
      errno = 13
      filename = 'session1.txt'
      strerror = 'Permission denied'
      is session1.txt a new file that hasn't been created? of has it been created and some other processes are using it? another possibility is the current user running the script does not have permission to write to this file. check the permission for this file or ask the administrator.

      Comment

      • uthalcyon
        New Member
        • Mar 2007
        • 6

        #4
        os.chmod(...)
        Change the access permissions of a file.

        Comment

        Working...