Giter VIP home page Giter VIP logo

hermes's Introduction

hermes

Description

A Rust program that connects to a server via FTP, lists the files in a specified directory, and copies files with a given file extension to a local directory. If specified, it can also delete the original files from the server.

The code is divided into two main parts: CLI argument parsing and FTP file copying.

Example:

.\hermes.exe --ip "192.168.1.42" --port "21" -u "user" -f "folder" -e "csv" -o "destination/" -d

Dependencies

  • anyhow crate for error handling
  • clap crate for CLI argument parsing
  • suppaftp crate for FTP file handling

CLI Arguments

The following arguments are supported:

  • ip - IP address of the server (required)
  • port - port number of the server (optional, defaults to 21)
  • user - username for FTP authentication (optional, defaults to "")
  • password - password for FTP authentication (optional, defaults to "")
  • folder - folder on the server to list and copy files from (optional, defaults to "")
  • extension - file extension to copy (optional, defaults to "bmp")
  • output - local folder to copy files to (optional, defaults to "")
  • delete - flag to indicate whether to delete original files from server after copying (optional, defaults to false)

Code Structure

The main function is the entry point of the program. It performs the following steps:

  1. Parse CLI arguments using Args::parse() function from the args module.
  2. Connect to the FTP server using FtpStream::connect() function from the suppaftp module.
  3. Login to the server using FtpStream::login() function from the suppaftp module.
  4. Change the working directory on the server using FtpStream::cwd() function from the suppaftp module.
  5. List files in the target directory using FtpStream::list() function from the suppaftp module.
  6. Iterate over all files in the directory.
  7. Check if the file has the desired extension.
  8. If it does, retrieve the file using FtpStream::retr_as_buffer() function from the suppaftp module.
  9. Write the file to disk using File::create() and File::write_all() functions from the std module.
  10. Delete the file from the server (if desired) using FtpStream::rm() function from the

Compiling

Complied using cargo >= 1.63. This can be installed via the rustup toolchain.

Credits

hermes's People

Contributors

antonioaja 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.