diff --git a/individual-files/Procedure.java b/individual-files/Procedure.java deleted file mode 100644 index 6d2a348..0000000 --- a/individual-files/Procedure.java +++ /dev/null @@ -1,38 +0,0 @@ -import java.lang.Runtime; -import java.io.*; - -public class Procedure extends HttpServlet -{ - public void doGet(HttpServletRequest req, HttpServletResponse res) - throws ServletException, IOException - { - res.setContentType("text/html"); - ServletOutputStream out = res.getOutputStream(); - out.println("
");
-
- String user = req.getParameter("user");
- if(user != null) {
- try {
- String[] args = { "/bin/sh", "-c", "finger " + user };
- Process p = Runtime.getRuntime().exec(args);
- BufferedReader fingdata = new BufferedReader(new InputStreamReader(p.getInputStream()));
- String line;
- while((line = fingdata.readLine()) != null)
- out.println(line);
- p.waitFor();
- catch(Exception e) {
- throw new ServletException(e);
-
- else {
- out.println("specify a user");
-
-
- out.println("");
- out.close();
-
- }
- }
- }
- }
- }
-}
diff --git a/individual-files/ServerThread.java b/individual-files/ServerThread.java
deleted file mode 100644
index 9d9e6e2..0000000
--- a/individual-files/ServerThread.java
+++ /dev/null
@@ -1,49 +0,0 @@
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.List;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-public class ServerThread {
- public static void main(String args[]) throws Exception {
- int PORT = 5555; // Open port 5555
-
- //open socket to listen
- ServerSocket server = new ServerSocket(PORT);
- Socket client = null;
-
- while (true) {
- System.out.println("Waiting for client...");
-
- // open client socket to accept connection
- client = server.accept();
-
- System.out.println(client.getInetAddress()+" contacted ");
- System.out.println("Creating thread to serve request");
-
- SThread student = new SThread(client);
- student.start();
- }
- }
-}
-
-public class SThread extends Thread {
- Socket client;
-
- public SThread(Socket x) {
- client = x;
- }
-
- public void run() {
- // create object to send information to client
- PrintWriter out = new PrintWriter(client.getOutputStream(),true);
-
- out.println("Student name: ");//send text to client;
- }
-}
-
diff --git a/individual-files/command.py b/individual-files/command.py
deleted file mode 100755
index 2894408..0000000
--- a/individual-files/command.py
+++ /dev/null
@@ -1,159 +0,0 @@
-import abc
-import os
-
-
-class Command(object):
- """The command interface."""
-
- __metaclass__ = abc.ABCMeta
-
- @abc.abstractmethod
- def execute(self):
- """Method to execute the command."""
- pass
-
- @abc.abstractmethod
- def undo(self):
- """A method to undo the command."""
- pass
-
-
-class LsCommand(Command):
- """Concrete command that emulates ls unix command behavior."""
-
- def __init__(self, receiver):
- self.receiver = receiver
-
- def execute(self):
- """The command delegates the call to its receiver."""
- self.receiver.show_current_dir()
-
- def undo(self):
- """Can not undo ls command."""
- pass
-
-
-class LsReceiver(object):
- def show_current_dir(self):
- """The receiver knows how to execute the command."""
-
- cur_dir = './'
-
- filenames = []
- for filename in os.listdir(cur_dir):
- if os.path.isfile(os.path.join(cur_dir, filename)):
- filenames.append(filename)
-
- print 'Content of dir: ', ' '.join(filenames)
-
-
-class TouchCommand(Command):
- """Concrete command that emulates touch unix command behavior."""
-
- def __init__(self, receiver):
- self.receiver = receiver
-
- def execute(self):
- self.receiver.create_file()
-
- def undo(self):
- self.receiver.delete_file()
-
-
-class TouchReceiver(object):
- def __init__(self, filename):
- self.filename = filename
-
- def create_file(self):
- """Actual implementation of unix touch command."""
- with file(self.filename, 'a'):
- os.utime(self.filename, None)
-
- def delete_file(self):
- """Undo unix touch command. Here we simply delete the file."""
- os.remove(self.filename)
-
-
-class RmCommand(Command):
- """Concrete command that emulates rm unix command behavior."""
-
- def __init__(self, receiver):
- self.receiver = receiver
-
- def execute(self):
- self.receiver.delete_file()
-
- def undo(self):
- self.receiver.undo()
-
-
-class RmReceiver(object):
- def __init__(self, filename):
- self.filename = filename
- self.backup_name = None
-
- def delete_file(self):
- """Deletes file with creating backup to restore it in undo method."""
- self.backup_name = '.' + self.filename
- os.rename(self.filename, self.backup_name)
-
- def undo(self):
- """Restores the deleted file."""
- original_name = self.backup_name[1:]
- os.rename(self.backup_name, original_name)
- self.backup_name = None
-
-
-class Invoker(object):
- def __init__(self, create_file_commands, delete_file_commands):
- self.create_file_commands = create_file_commands
- self.delete_file_commands = delete_file_commands
-
- def create_file(self):
- print 'Creating file...'
-
- for command in self.create_file_commands:
- command.execute()
- self.history.append(command)
-
- print 'File created.\n'
-
- def delete_file(self):
- print 'Deleting file...'
- for command in self.delete_file_commands:
- command.execute()
- self.history.append(command)
- print 'File deleted.\n'
-
- def undo_all(self):
- print 'Undo all...'
-
- for command in reversed(self.history):
- command.undo()
-
- print 'Undo all finished.'
-
-
-if __name__ == '__main__':
- # Client
-
- # List files in current directory
- ls_receiver = LsReceiver()
- ls_command = LsCommand(ls_receiver)
-
- # Create a file
- touch_receiver = TouchReceiver('test_file')
- touch_command = TouchCommand(touch_receiver)
-
- # Delete created file
- rm_receiver = RmReceiver('test_file')
- rm_command = Rm - Command(rm_receiver)
-
- create_file_commands = [ls_command, touch_command, ls_command]
- delete_file_commands = [ls_command, rm_command, ls_command]
-
- invoker = Invoker(create_file_commands, delete_file_commands)
-
- invoker.make_file()
- invoker.delete_file()
- invoker.undo_all()
diff --git a/individual-files/facilities.c b/individual-files/facilities.c
deleted file mode 100644
index 84dbccf..0000000
--- a/individual-files/facilities.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include