BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C语言代写 | CS360 Lab Assignment #3 : sh Simulator

C语言代写 | CS360 Lab Assignment #3 : sh Simulator

本次美国代写是C语言sh模拟器相关的一个Lab Assignment

This assignment is the Programming Project: sh Simulator in Chapter 3.11
Purpose: Understand how Unix/Linux sh works by using fork/exec/wait/pipe.

String operations

REQUIREMENTS

Write a C program, mysh, which simulates the Unix sh for command processing.

Read Chapter3-11 for details

SAMPLE SOLUTION:

~samples/LAB3/lab3.bin          (down load and run under Linux)

CS360 LAB3 Check List

WARNING: ZERO points if turn in only the lab3base.c code

Make sure you have a LARGE text file such as t.c of YOUR LAB3 C code file

1.  Simple commands:20 points

start YOUR mysh program, run the following commnads

ls -l       # ls LONG format
cat t.c     # show t.c contents

Other Linux commands, e.g. date, mkdir abc, rmdir abc, touch filename

Choose an Editor that suits you : emacs, vi, gedit, nano

emacs t.c   # must be able to edit your file       cc t.c

# must be able to compile and link your t.c file      a.out
# run another instance of your mysh program      exit
# back to the original mysh

2. I/O redirections:20 points

cat < t.c                     # cat your t.c file
cat t.c  > outfile; ls -l     # must show outfile same as t.c
cat t.c >> outfile; ls -l     # must show outfile size doubled

3. PIPES:30 points

cat t.c | grep printf         # must show the piped outputs
cat t.c | grep printf | more  # 2 pipes

4. BONUS for MULTIPLE pipes with I/O redirection, e.g. 10 points

cat < t.c | cat | cat | grep printf > outfile

During DEMO, TA will ask you these questions:

Answer these questions in YOUR program code:20 points

1. show where and HOW do you tokenize PATH into dir pointers.

2. show where and how do you execute SIMPLE commands (no I/O redirect, no pipe)

3. show how do you handle > for output redirection

4. For the command line

ls -l -a > outfile   what’s argv[] passed to the ls program? WHY?

5. show where and how do you handle pipe command, e.g. cmd1 | cmd2

bestdaixie

评论已关闭。