HP3000-L Archives

March 2000, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Bill Cadier <[log in to unmask]>
Reply To:
Bill Cadier <[log in to unmask]>
Date:
Mon, 6 Mar 2000 14:32:28 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (57 lines)
Hi Guy,

Here's a sample C program that chmod's a file:

#define _POSIX_SOURCE
#include <stdio.h>
#include <sys/stat.h>

void main()
{

   chmod("myfile", S_IROTH | S_IWOTH | S_IXOTH );

}

You construct the mode specs from the constants found in
/usr/include/sys/stat.h (see chmod(2) on an HPUX box).

So this sample program would take the file 'myfile' which might look like
this:

-rw-rw----   1 MGR.HOTSITE       HOTSITE        0 Mar  6 14:15 myfile

And change it's access to this:

-------rwx   1 MGR.HOTSITE       HOTSITE        0 Mar  6 14:15 myfile

Which in real life might be pretty pointless but hey, it's an example!

Hope this helps!
+---------------------------------------------------------------------+
|Bill Cadier                  | There ain't a horse that can't be rode|
|Hewlett-Packard Co.          | nor a cowboy that can't be throwed.   |
|Commercial Systems Division  |                                       |
|Albuquerque, New Mexico      |                                       |
[log in to unmask]   |                                       |
+---------------------------------------------------------------------+

-----Original Message-----
From: Guy Paul <[log in to unmask]>
To: [log in to unmask] <[log in to unmask]>
Date: Monday, March 06, 2000 1:09 PM
Subject: How to chmod in C pgm


>I need to do a chmod on a file withing a C program. Not being a
>C programmer, I was wondering if one of you on the list could
>give me an example of how this could be accomplished.
>
>TIA...
>
>Guy Paul
>[log in to unmask]
>AIT Operations
>Hewlett-Packard
>

ATOM RSS1 RSS2