Coder Social home page Coder Social logo

bugbase-socket-programming's Introduction

BugBase-Socket-Programming

This project implements a simple file transfer and command execution system using Python socket programming. It consists of two scripts: script1.py and script2.py.

The project enables users to upload a file from one script to another over a network connection. The receiving script saves the uploaded file, executes a command on it (such as determining the file type), and sends the command output back to the sender.

This system is useful for scenarios where files need to be transferred and processed remotely, such as automated file processing or remote administration tasks. It serves as a learning exercise for understanding network communication and file handling in Python.

How it Works:

script1.py:

File Upload:

  • Establishes a connection to a server at a specified host and port.
  • Sends the name and size of the file to be transferred.
  • Sends the file content in chunks over the network using a socket connection.

script2.py:

File Reception and Command Execution:

  • Listens for incoming connections on the specified port.
  • Receives the name and size of the file to be transferred.
  • Receives the file content in chunks over the network.
  • Saves the received file to a designated directory.
  • Executes a command on the received file (in this case, the file command to determine the file type).
  • Sends the command output back to the client.

Installation

Windows and Linux

  1. Clone the repository:
    git clone https://github.com/Jaswanthravichandran/BugBase-Socket-Programming.git
    
  2. Navigate to the project directory:
    cd BugBase-Socket-Programming
    
  3. Run the setup script:
    python Setup.py
    

Note

You can install the Python requirements manually if you face any issues in setup.py

  1. Install python requirements:
    pip install -r requirements.txt
    
    

Tip

Feeling lazy to set up, then try to run it on docker image.

  1. Pull the Docker image:

    docker pull jaswanthravichandran/socket:latest
    
  2. Run the Docker Image:

    docker run -p 9000:9000 image_name
    
  3. Run the Script1.py:

    • Now run the Script1.py from your localhost.
    python Script1.py 'filename' localhost 9000
    

Usage

  1. Run the Script2.py first with the following command:
    python Script2.py <port>
    
  2. Then run the Script1.py with the following command:
    python Script1.py <'filepath'> <host> <port>
    

Usage Examples

video here

Example Image

Example Image

Example Image

bugbase-socket-programming's People

Contributors

jaswanthravichandran avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.