summaryrefslogtreecommitdiff
path: root/1088/CH23/EX23.10/Result10.txt
diff options
context:
space:
mode:
Diffstat (limited to '1088/CH23/EX23.10/Result10.txt')
-rwxr-xr-x1088/CH23/EX23.10/Result10.txt150
1 files changed, 150 insertions, 0 deletions
diff --git a/1088/CH23/EX23.10/Result10.txt b/1088/CH23/EX23.10/Result10.txt
new file mode 100755
index 000000000..0866933af
--- /dev/null
+++ b/1088/CH23/EX23.10/Result10.txt
@@ -0,0 +1,150 @@
+ ans =
+
+ 1.
+
+-->exec('Example10.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 10 : Show the method of listing only directories in systems programming
+
+ ****************************************************************
+
+ 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 lsdir.c # to open the file emp.lst /* Program lsdir.c -- Lists only directories using S_IFMT and S_ISDR macros */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <dirent.h>
+
+int main(int argc,int **argv){
+ DIR *dir;
+ struct dirent *direntry; /* Returned by readdir() */
+ struct stat statbuf; /* Address of statbuf used by lstat() */
+ mode_t file_type, file_perm;
+
+ if ((dir = opendir(argv[1])) == NULL)
+ quit("Couldn't open directory",1);
+ if((chdir(argv[1]) == -1)) /* Change to directory before */
+ quit("chdir",2); /* you starting reading its entries*/
+
+ while ((direntry = readdir(dir)) != NULL) { /* Read each entry in directory*/
+ if (lstat(direntry->d_name,&statbuf) < 0){ /* dname must be in */
+ perror("lstat"); /*current directory */
+ continue;
+ }
+ if (S_ISDIR(statbuf.st_mode)) { /*If file is a directory */
+ file_type = statbuf.st_mode & S_IFMT;
+ file_perm = statbuf.st_mode & -S_IFMT;
+ printf("%o %4o %s\n", file_type, file_perm, direntry->d_name);
+ }
+ }
+ exit(0);
+}
+ $ cc lsdir.c
+# Enter the name of the directory as command-line argument which you want to access
+ 40000 755 $Recycle.Bin
+40000 755 $SysReset
+40000 755 Boot
+40000 755 bootmgr
+40000 755 BOOTNXT
+40000 755 BOOTSECT.BAK
+40000 755 Dev-Cpp
+40000 755 Documents and Settings
+40000 755 Downloads
+40000 755 Dwimperl
+40000 755 eula.1028.txt
+40000 755 eula.1031.txt
+40000 755 eula.1033.txt
+40000 755 eula.1036.txt
+40000 755 eula.1040.txt
+40000 755 eula.1041.txt
+40000 755 eula.1042.txt
+40000 755 eula.2052.txt
+40000 755 eula.3082.txt
+40000 755 globdata.ini
+40000 755 hiberfil.sys
+40000 755 install.exe
+40000 755 install.ini
+40000 755 install.res.1028.dll
+40000 755 install.res.1031.dll
+40000 755 install.res.1033.dll
+40000 755 install.res.1036.dll
+40000 755 install.res.1040.dll
+40000 755 install.res.1041.dll
+40000 755 install.res.1042.dll
+40000 755 install.res.2052.dll
+40000 755 install.res.3082.dll
+40000 755 odf
+40000 755 pagefile.sys
+40000 755 PerfLogs
+40000 755 Perl64
+40000 755 Program Files
+40000 755 Program Files (x86)
+40000 755 ProgramData
+40000 755 Remote Programs
+40000 755 S
+40000 755 swapfile.sys
+40000 755 System Volume Information
+40000 755 UserGuidePDF
+40000 755 Users
+40000 755 VC_RED.cab
+40000 755 VC_RED.MSI
+40000 755 vcredist.bmp
+40000 755 Windows
+
+
+
+$ 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)