ans = 1. -->exec('Example12.sci') -->clear -->flag=1 flag = 1. -->mode(-1) Current date is 23-Jun-2013 Welcome to the Textbook Companionship Project 2013 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Book Title : UNIX CONCEPTS AND APPLICATIONS Book Edition : 4 Book Author : Sumitabha Das +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Code Author : Pranav Bhat T +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Chapter Number : 23 Chapter Title : Systems programming I- Files +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Example 12 : Show the file access rights of a file using the read UID and GID **************************************************************** Answer : INSTRUCTIONS : 1.These programs are part of systems programming in Unix and the commands have NO EQUIVALENT IN SCILAB 2.However if possible some selected programmes have been TRIED TO BE IMPLEMENTED 3.For most of the programmes whose equivalent is NOT THERE IN SCILAB,only the output has been printed as given in the textbook w ith no interactive input as in the programme below 4.However the .c files which are displayed here are also made into a seperate file.If you are a unix user then try compiling and running the programme with gcc or cc compiler 5.The inconvenience is regretted. .............Press [ENTER] to continue..... UNIX SHELL SIMULATOR(DEMO VERSION WITH PRELOADED COMMANDS) $ cat faccess.c # to open the file emp.lst /*Program: faccess.c -- Determines a file's access rigths using read UID and GID */ #include #include void quit(char *,int); int main(int argc, char *argv[]) { short count; for (count = 1; count < argc ;++count) { printf("%s ",argv[count]); if (access(argv[count],F_OK) == -1) quit("File not found",1); if (access(argv[count],R_OK) == -1) printf("Not readable "); if (access(argv[count],W_OK) == -1) printf("Not writable "); if (access(argv[count],X_OK) == -1) printf("Not executable "); printf("\n"); } exit(0); } $ cc faccess.c $ a.out /etc/passwd /etc/shadow /etc/passwd: Not writable Not executable /etc/shadow: Not readable Not writable Not executable $ exit #To exit the current simulation terminal and return to Scilab console ........# (hit [ENTER] for result) BACK TO SCILAB CONSOLE... Loading initial environment -->diary(0)