ans = 1. -->exec('Example7.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 7 : Show the method of directory navigation with chdir and getcwd **************************************************************** 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 dir.c # to open the file emp.lst /* Program: dir.c -- Directory navigation with chdir and getcwd */ #include #define PATH_LENGTH 200 void quit(char *,int ); /* Prototyoe definition */ int main(int argc, char **argv) { char olddir[PATH_LENGTH + 1]; /* Extra character for null */ char newdir[PATH_LENGTH + 1]; if (getcwd(olddir, PATH_LENGTH) == -1) /* Getting current directory */ quit("getcwd", 1); printf("pwd: %s\n",olddir); if ((chdir(argv[1]) == -1)) /* Changing to another directory */ quit("chdir", 2); printf("cd: %s\n", argv[1]); getcwd(newdir, PATH_LENGTH); /* getting new directory */ printf("pwd: %s\n",newdir); exit(0); } $ cc dir.c # Please enter the name of the directory which you want to go as the command line argument pwd: C:\Users\Pranav Bhat\Documents\TCPMUM\Chapter23 cd: / pwd: / Change of directory inside program $ pwd C:\Users\Pranav Bhat\Documents\TCPMUM\Chapter23 ...is not available outside it $ 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)