, , , , , ,

[SOLVED] Csci 4547 / 6647 program 1: hello shell

$25

File Name: Csci_4547___6647_program_1__hello_shell.zip
File Size: 367.38 KB

5/5 - (1 vote)

1. To use a Unix system. If you are running a Windows system, you must install a Unix system
(Fedora Linux) and desktop (KDE) on your machine. Mac users already have a version of
Unix. Be sure the Developer Tools are installed.
2. To open a shell in a terminal window on your system. I use tcsh. You will probably use bash.
3. To learn the form of and parts of a command line.
4. To learn about what a shell does with a command line, including quotes and wild cards.
5. To compile and run a C or C++ program without using an IDE. (Use your IDE to write it.)
6. To use standard file output in either C or C++. (Don’t cut-and-paste or turn in screen shots).
2 The Program
• Write a program to print out command line arguments. Your main function should accept
arguments from the command shell, as follows:
int main( int argc, char* argv[] ){}
The array named argv contains the white-space delimited text fields from the command line,
with patterns expanded and quotes “managed”; argc is the number of elements in this array,
excluding the last array element, which contains NULL.
aliceP1 -au w/java/ eliza.newhaven.edu:w/java/
aliceP1
-au
w/java/
4
argc argv
eliza.newhaven.edu:w/java/
Command line:
(Note: this is a null pointer.)
• In your program, open an output stream in append mode, using “P1_” followed by your own
last name as part of the file name. For this course, PLEASE do not put spaces into your file
names. Example: “P1_Fischer.txt”
In C: FILE* out = fopen( “P1_Jones.txt”, “a”)
In C++: ofstream myOut( “P1_Jones.txt”, ios::out | ios::app)
By using append mode, you will be able to store the results from all the runs in one file.
• To begin, print a dashed line, as a divider. Then, starting with argv[0], list, the parts of the
command, one per line, with a label for each. For argv[0], print “command”. If the arg starts
with a “-”, print “switch”. Otherwise, print “argument”.
The output for the command given above should look like this:
———————————–
command P1
switch au
argument w/java/
argument eliza.newhaven.edu:w/java/
• In C, use printf to print your results to the screen and ALSO use fprintf to write to your file.
In C++, use << to send output to both cout and your own stream. You will try your program with several different command lines. The command lines do not need to make sense. They do need to exercise the possibilities. In your tests, include redirection directives and glob patterns. 3 Installation 1. If you need help installing Fedora Linux or KDE, ask Mark Morton. 2. If you want to run both Windows and Unix, the best way is to make Unix the basic system, install VirtualBox, and run Windows inside of the Virtual box. Second best is to make a dual-boot system. 3. If you can’t get a Unix system installed by Tuesday, use one of the Macs in the lab for your homework. DO NOT procrastinate. 4 Testing 1. Navigate to the directory that contains your .c or .cpp file. Then use one of these compile commands for Program 1: gcc -std=c99 -Wall -o yourName yourSource.c g++ -std=c++11 -Wall -o yourName yourSource.cpp clang++ -std=c++11 -Wall -o yourName yourSource.cpp Example: gcc -o P1 main.c This will produce an executable file (command) named “P1” in the current working directory. 2. In that same directory, create two or three dummy files (they can be empty) with names ending in .bak 3. Execute the command ls -l > P1_Jones.txt (Use your own name.)
This will put a directory listing into your output so that I can grade your work.
4. Run your new command six times, using the tests below, but substituting the full name of
your executable file for P1.
(a) P1
(b) P1 -o myCommand myMain.c myClass.c
(c) P1 w/java bash-3.2 ls -l
(d) P1 -au –verbose w/java/ kira:w/java/
(e) P1 -i “CSCI 6657” *.html > mytemp.txt 3
(f) P1 *.bak *.log
5. When testing is finished, five of the tests will also be in P1_Jones.txt and one will be in
mytemp.txt. Write some comments at the end of your source code file that explain what you
see and what you do not see for tests (e) and (f).
6. Turn in your code (with your explanations) and the two output files. Due Wed, Sept. 2.

Shopping Cart

No products in the cart.

No products in the cart.

[SOLVED] Csci 4547 / 6647 program 1: hello shell[SOLVED] Csci 4547 / 6647 program 1: hello shell
$25