Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tutorial 6 Assignment 2. If using C gcc is most likely installed by default. Otherwise, you need to install it Submit your source code file with extension.c.

Similar presentations


Presentation on theme: "Tutorial 6 Assignment 2. If using C gcc is most likely installed by default. Otherwise, you need to install it Submit your source code file with extension.c."— Presentation transcript:

1 Tutorial 6 Assignment 2

2 If using C gcc is most likely installed by default. Otherwise, you need to install it Submit your source code file with extension.c (A2com.c) Create a file and name it makefile (no extension) and submit it as well Put the following two lines in it A2com : A2com.c gcc -o A2com A2com.c N.B. you must indent this line with tab

3 If using C cont. To compile and run your code from your terminal, type: make chmod u+x A2com./A2com

4 If using C Running the “ls -l” command: – system(“ls -l”);

5 If using Java Install java Submit your source code file with extension.java (A2com.java) Create a file and name it makefile (no extension) and submit it as well Put the following two lines in it A2com.class: A2com.java javac A2com.java N.B. you must indent this line with tab

6 If using Java cont. Create and submit a shell script called A2com with NO extension which calls “java A2com” To compile and run your code from your terminal, type: make chmod u+x A2com./A2com

7 If using Java cont. If you have more than one source file, the makefile can be done like A2com.class: A2com.java A2comextra.java javac A2com.java A2comextra.java N.B. you must indent this line with tab

8 (ListOutput.java) program which demonstrates how to call the “ls -l” command from Java import java.io.*; public class ListOutput { public static void main(String[] args) throws IOException, InterruptedException { Runtime rt = Runtime.getRuntime(); Process p = rt.exec("ls -l"); p.waitFor(); BufferedReader lsOutput = new BufferedReader(new nputStreamReader(p.getInputStream())); String line; while ((line = lsOutput.readLine()) != null) { System.out.println(line); }

9 If using Ruby Install Ruby Either you submit your Ruby solution (A2com) with NO.rb extension and with #!/usr/bin/env ruby) as the first line in your code Or you submit your Ruby solution (A2com.rb), and a shell script called A2com with NO.rb extension which calls “ruby A2com.rb” To compile and run your code: chmod u+x A2com./A2com

10 If using Python Install Python3. You might already have it. Either you submit your Python solution (A2com) with NO.py extension and with (#!/usr/bin/env python3) as the first line in your code Or you submit your Python solution (A2com.py), and a shell script called A2com with NO.py extension which calls “python3 A2com.py” To compile and run your code: chmod u+x A2com./A2com

11 If using Python Running the “ls -l” command: – os.system(‘ls -l’)

12 If using Bash Most likely is installed by default Either you submit your Bash solution (A2com) with NO.sh extension and with #!/usr/bin/env bash) as the first line in your code Or you submit your Bash solution (A2com.sh), and a shell script called A2com with NO.sh extension which calls “bash A2com.sh” To compile and run your code: chmod u+x A2com./A2com

13 Testing Your work The program must accept commands typed at the terminal window It must also work correctly if the marker redirects input to the program from a file, e.g. make (if you have a makefile) chmod u+x A2com./A2com< test1.txt./A2com < test2.txt./A2com < test3.txt./A2com < test4.txt./A2com < test5.txt./A2com < test6.txt./A2com < testspaces.txt


Download ppt "Tutorial 6 Assignment 2. If using C gcc is most likely installed by default. Otherwise, you need to install it Submit your source code file with extension.c."

Similar presentations


Ads by Google