summaryrefslogtreecommitdiff
path: root/1088/CH21/EX21.4/Result4.pdf
blob: b304ea62515467c7e6fa8350106b492dda7e9e78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
 ans  =
 
    1.  
 
-->exec('Example4.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                    :                                                                            21   
 
 Chapter Title                         :                                Advanced Shell Programming   
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Example 4    :               Show the method of using exec command to make many streams 
 
 ****************************************************************   
 
 Answer    :      
 
 INSTRUCTIONS   :    

1. Here all instructions are preloaded in the form of a demo

Initially the whole perl script is displaying and then 
 the result of the same can be seen in the command line interpreter.

2. PLEASE MAKE SURE THAT THE PERLSCRIPT INTERPRETER
EXISTS IN THE SYSTEM
OR THE COMMAND WOULD NOT WORK 

3. PRESS ENTER AFTER EACH COMMAND to see its RESULT

5. PRESS ENTER AFTER EACH RESULT TO GO TO THE NEXT COMMAND
.............Press [ENTER] to continue.....	UNIX SHELL SIMULATOR(DEMO VERSION WITH PRELOADED COMMANDS)




$ cat emp.lst      # to open the file emp.lst 2233|a.k.shukla             |g.m.        |sales           |12/12/52|6000
9876|jai sharma             |director  |production |12/03/50|7000
5678|sumit chakrobarty|d.g.m      |marketing  |19/04/43|6000
2356|barun sengupta      |director  |personnel  |11/05/47|7800
5423|n.k. gupta              |chairman |admin       |30/08/56|5400
1006|chanchal singhvi   |director  |sales          |03/09/38|6700
6213|karuna ganguly      |g.m.        |accounts   |05/06/62|6300
1265|s.n. dasgupta         |manager  |sales          |12/09/63|5600
4290|jayant Choudhary  |executive |production|07/09/50|6000
2476|anil aggarwal        |manager   |sales          |01/05/59|5000
6521|lalit chowdury       |director    |marketing |26/09/45|8200
3212|shyam saksena      |d.g.m        |accounts   |12/12/55|6000
3564|sudhir Agarwal     |executive  |personnel  |06/07/47|7500
2345|j.b. saxena            |g.m.           |marketing |12/03/45|8000
0110|v.k. agrawal         |g.m.           |marketing  |31/02/40|9000

# Enter the name of the shellscript file whichever you desire  

 #!/bin/sh
# Script: countpat.sh -- Uses exec to handle multiple files
#
exec > $2                # Open file 1 for storing selected lines
exec 3> $3               # Open file 3 for storing patterns not found
exec 4> $4               # Open file 4 for storing invalid patterns

[ $# -ne 4 ] && { echo "4 arguments required" ; exit 2 ; }

exec < $1                 # Redirecting output
while read pattern ; do 
      case "$pattern" in
             ????) grep $pattern emp.lst ||
                   echo $pattern not found in file 1>&3 ;;
                *) echo $pattern not a four-character string 1>&4 ;;
      esac
done
exec > \/dev/tty        # Redirects standard output back to terminal
echo Job Over
 
# type the following command in the command line interpreter as soon as it appears 
       "  h.sh     " [COMMANDLINE ARGUMENTS][ENTER]


$ h.sh  [COMMANDLINE ARGUMENTS]             #to execute the perlscript 


   ---------------->Executing ShellScript in Command Line Prompt<-------------- 


$ 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)