/* Program to print details including owner access permissions, file access time, where file name is given as a command line argument.
*/
#include<stdio.h>
#include<sys/stat.h>
int main(int argc, char *argv[3])
{
int i,statchmod;
struct stat buffer;
printf("Give file name:\n");
for(i=1;i<argc;i++)
{
printf("file=%s:-\n",argv[1]);
if(stat(argv[i], &buffer)<0)
printf("Error in file stated");
else
statchmod=buffer.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
printf("Access permission(in octal): %o\n",statchmod);
printf("Owenered=%d,gid=%d\n",buffer.st_uid,buffer.st_gid);
printf("Access time=%d\n", (time(&(buffer.st_atime))));
}
}
OUTPUT SCREEN:
*/
#include<stdio.h>
#include<sys/stat.h>
int main(int argc, char *argv[3])
{
int i,statchmod;
struct stat buffer;
printf("Give file name:\n");
for(i=1;i<argc;i++)
{
printf("file=%s:-\n",argv[1]);
if(stat(argv[i], &buffer)<0)
printf("Error in file stated");
else
statchmod=buffer.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
printf("Access permission(in octal): %o\n",statchmod);
printf("Owenered=%d,gid=%d\n",buffer.st_uid,buffer.st_gid);
printf("Access time=%d\n", (time(&(buffer.st_atime))));
}
}
OUTPUT SCREEN:
No comments:
Post a Comment