#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    81
    Rep Power
    12

    ReDirect Problem


    when I want to redirect output of a program to a file, why does the file appear as an executable after the data has been written to it? Here is the line that opens the file
    open(filename,O_WRONLY|O_CREAT|O_TRUNC,S_IRWXU);
    Thanks!
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,183
    Rep Power
    2222
    S_IRWXU means "read, write, execute -- user" and should generate a file mode of 0700.

    Read-only for owner is S_IRUSR and write-only is S_IWUSR. You might get the "read & write, but not execute" with (S_IRUSR | S_IWUSR).

    Otherwise, you might want to set your umask to mask out the execute (umask == 0111). Or call chmod() to turn executable off.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    81
    Rep Power
    12

    Thanks!


    It works I am just using S_IREAD|S_IWRITE.

IMN logo majestic logo threadwatch logo seochat tools logo