Skip to content

Edward-game-scr/Socket-and-File-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Write/Read App - Operating Systems - Homework Project

1. Introduction

This project demonstrates a file management system implemented using Bash scripts and socket programming. It provides a web interface for local interactions using a minimal HTML form and a TCP-based client-server system for remote communication.


2. Objectives

  • Provide basic file operations (create, read, list, and delete) via web and socket interfaces.
  • Demonstrate Linux socket communication using Bash and Netcat.
  • Integrate a minimal web server with CGI for backend processing.

3. System Setup

Web Server

  • Install nginx using:
    bash
    Copy code
    sudo apt update sudo apt install nginx
  • Enable CGI for handling Bash scripts in the /usr/lib/cgi-bin/ directory.

Directory and File Permissions

  • Create a directory for files:
    bash
    Copy code
    mkdir /tmp/server_files chmod 777 /tmp/server_files
  • Ensure all scripts are executable:
    bash
    Copy code
    chmod +x file_manager.sh tcp_server.sh tcp_client.sh

4. Script Descriptions

index.html

Provides a web-based interface for file management with buttons to send data via forms.

file_manager.sh

Processes commands from the web interface, supporting save, read, and clear file operations.

tcp_server.sh

Implements a TCP socket server. Listens for commands (WRITE, READ, LIST, DELETE, EXIT) and processes them.

tcp_client.sh

A client script that connects to the server, sends commands, and displays responses.


5. How to Run

  1. Start the Web Server
    bash
    Copy code
    sudo systemctl start nginx
  2. Place Scripts
    • index.html and file_manager.sh in /usr/lib/cgi-bin/.
    • Ensure permissions with chmod +x.
  3. Start the TCP Server
    bash
    Copy code
    ./tcp_server.sh
  4. Run the TCP Client
    bash
    Copy code
    ./tcp_client.sh

6. Commands

Command | Description | Example -- | -- | -- WRITE | Writes content to a file. | WRITE myfile.txt Hello, world! READ | Reads and displays file content. | READ myfile.txt LIST | Lists all files in the directory. | LIST DELETE | Deletes a specified file. | DELETE myfile.txt EXIT | Stops the server. | EXIT

7. Conclusion

This project showcases a fully functional file management system using Linux-native tools and demonstrates the integration of Bash scripting with both web and socket communication.


8. Future Improvements

One potential improvement for this project is implementing user authentication and access control. Currently, the system allows unrestricted access to all file operations. Adding a user login mechanism with different permission levels would enhance security and demonstrate more advanced system administration concepts.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors