#ACSL1516S1. CHMOD
CHMOD
PROBLEM: CHMOD is a command in the UNIX computer system. It is the command used for giving users permissions to access and change files and directories. There are 3 classes of users. They are the owner, the group and others. The permissions given are: read(r), write(w) and execute(x).
The argument of the CHMOD command is a 3-character octal number (ex. 526). When each digit of that number is converted to binary, the binary digits are paired to represent read, write and execute in that order. 526 would convert to 101 010 110.
The first binary conversion gives the user permissions. The second gives the group permissions. The third gives the others permissions. So here, the owner has read and execute permissions and that is represented by r-x. The group has only write permission given by -w-. The others class has read and write permissions as given by rw-.
Putting all of the above together CHMOD 526 = 101 010 110 = r-x -w- rw-
Further, a fourth octal digit can be added on the left. This digit gives special permissions such as the ability to change passwords, rename files and delete files. The permissions only apply if the class already has the execute permission. A special permission of 0 indicates no special permissions are granted. A special permission of 1 applies only to the owner. A special permission of 2 applies only to the group class. A special permission of 4 applies only to the others class. When the special permissions are applied to either the owner or group classes, the x is changed to an s. When applied to the others class, the x is changed to a t.
INPUT: There will be 5 lines of input. Each line will contain 4 octal digits.
OUTPUT: For each line of input, print the 9-bit binary conversion and the 9-character permission string. Print a space between each grouping as shown below. Both outputs must be correct to get the point.
SAMPLE INPUT
0,5,2,6
1,7,3,0
2,4,1,5
4,2,3,4
4,5,6,7
SAMPLE OUTPUT
101 010 110 and r-x -w- rw-
111 011 000 and rws -wx ---
100 001 101 and r-- --s r-x
010 011 100 and -w- -wx r--
101 110 111 and r-x rw- rwt