# ftp-tail

> A lightweight module to tail files over FTP or SFTP.

Latest version **2.1.1** (published 2024-08-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install ftp-tail
pnpm add ftp-tail
yarn add ftp-tail
bun add ftp-tail
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2024-08-08 |
| First published | 2020-06-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 15.8 KB |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Thomas Smyth |
| Maintainers | thomas-smyth |

## Links

- npm: https://www.npmjs.com/package/ftp-tail
- Repository: https://github.com/Thomas-Smyth/ftp-tail
- Homepage: https://github.com/Thomas-Smyth/ftp-tail#readme
- Issues: https://github.com/Thomas-Smyth/ftp-tail/issues
- npm.io page: https://npm.io/package/ftp-tail

## Dependencies (2)

- [basic-ftp](https://npm.io/package/basic-ftp.md) ^4.6.6
- [ssh2-sftp-client](https://npm.io/package/ssh2-sftp-client.md) ^10.0.3

## Recent versions

- 2.1.1 (latest) — 2024-08-08
- 2.1.0 — 2024-07-31
- 2.0.1 — 2021-08-14
- 2.0.0 — 2021-08-14
- 1.1.1 — 2020-10-22
- 1.1.0 — 2020-10-22
- 1.0.3 — 2020-10-14
- 1.0.2 — 2020-06-28
- 1.0.1 — 2020-06-27
- 1.0.0 — 2020-06-27

## README

<div align="center">

## ftp-tail

[![GitHub release](https://img.shields.io/github/release/Thomas-Smyth/ftp-tail.svg?style=flat-square)](https://github.com/Thomas-Smyth/ftp-tail/releases)
[![GitHub contributors](https://img.shields.io/github/contributors/Thomas-Smyth/ftp-tail.svg?style=flat-square)](https://github.com/Thomas-Smyth/ftp-tail/graphs/contributors)
[![GitHub release](https://img.shields.io/github/license/Thomas-Smyth/ftp-tail.svg?style=flat-square)](https://github.com/Thomas-Smyth/ftp-tail/blob/master/LICENSE)

<br>

[![GitHub issues](https://img.shields.io/github/issues/Thomas-Smyth/ftp-tail.svg?style=flat-square)](https://github.com/Thomas-Smyth/ftp-tail/issues)
[![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/Thomas-Smyth/ftp-tail.svg?style=flat-square)](https://github.com/Thomas-Smyth/ftp-tail/pulls)
[![GitHub issues](https://img.shields.io/github/stars/Thomas-Smyth/ftp-tail.svg?style=flat-square)](https://github.com/Thomas-Smyth/ftp-tail/stargazers)
<br><br>
</div>

## **About**
Need to tail a file on a remote server? ftp-tail should be able to help!

## **Motivation**
To collect the data we needed to build [SquadJS](https://github.com/Thomas-Smyth/SquadJS), a scripting framework for [Squad](https://joinsquad.com/) servers, we found we needed to tail the Squad server's log files. As a result of this, it became a requirement that SquadJS must be installed on the same machine as the Squad server, however, this prevented anyone using rented Squad server instances from using SquadJS. Thus, we endeavoured to make it possible for these logs files to be streamed over the FTP and SFTP servers provided by most hosts - ftp-tail is the outcome of this and we have opened-sourced it for others to benefit from.

## **Usage**
### **FTP**
```js
import { FTPTail } from 'ftp-tail';

(async () => {
  // Initiate FTPTail...
  const tailer = new FTPTail(
    {
      ftp: {
        // basic-ftp's .access options.
        host: "xxx.xxx.xxx.xxx",
        user: "user",
        password: "password",
        
        // As well as...
        timeout: 5 * 1000, // Timeout (optional).
        encoding: 'utf8' // Encoding (optional).
      },

      fetchInterval: 0, // Delay between polls.
      log: true // Enable logging (also accepts logging function).
    }
  );

  // Do something with the lines, e.g. log them.
  tailer.on('line', console.log);

  // Watch the file...
  await tailer.watch('/SquadGame.log');
  
  // Unwatch the file...
  await tailer.unwatch();
})();
```

### **SFTP**
```js
import { SFTPTail } from 'ftp-tail';

(async () => {
  // Initiate FTPTail...
  const tailer = new SFTPTail(
    {
      ftp: {
        // ssh2-sftp-client's .connect options.
        host: "xxx.xxx.xxx.xxx",
        username: "user",
        password: "password",
      },

      fetchInterval: 0, // Delay between polls.
      log: true // Enable logging (also accepts logging function).
    }
  );

  // Do something with the lines, e.g. log them.
  tailer.on('line', console.log);

  // Watch the file...
  await tailer.watch('/SquadGame.log');
  
  // Unwatch the file...
  await tailer.unwatch();
})();
```

## **Credits**
The logic behind ftp-tail was originally proposed, designed and implemented by [awn.gg](https://awn.gg/) - ftp-tail is an open-sourced re-implementation of their efforts.

---
_Source: https://npm.io/package/ftp-tail · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
