ans = 1. -->exec('Example5.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 5 : Print all the system call errors with perror **************************************************************** 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 show_errorno.c # to open the file emp.lst /* Program: show_errno.c -- Displaying system call errors with perror */ #include int main(int argc, char **argv) { int fd; char* filename = "non_existent_file"; /* This file must not exist */ fd = open(filename, O_RDONLY); /* File descriptor assigned first */ if (fd == -1) /* and then checked */ perror("no_existent_file"); if ((fd = open("/etc/shadow",O_RDONLY)) == -1) /* bOTH COMBINED HERE */ perror("shadow"); if ((fd = open("show_errno.c",O_WRONLY | O_CREAT | O_EXCL, 0744)) == -1) perror("show_errno.c"); exit(0); } $ cc show_errorno.c $ a.out non_existent_file: No such file or directory shadow: Permission denied show_errno.c: File exists $ 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)