Home RSS feed

Runtil

This little C program starts another executable and lets it run until a specified string is found in the executable's output.

Compile like so: gcc -o runtil runtil.c

Usage: ./runtil STOPSTRING FILE [ARG0] [ARG1]...
Execute FILE with arguments ARG0, ARG1, ..., and kill FILE if it writes STOPSTRING to standard out.

Example usage (not to support leeching): ./runtil seeding bittorrent-console file.torrent; bittorrent-console another.torrent

In the example, bittorrent-console is started with the argument "file.torrent". Runtil monitors the stdout of the process and kills it once it outputs the string "seeding".

If you have a *nix shell, there are other ways to accomplish this. For example: FILE | grep --max-count=1 STOPSTRING

Tags: c

blog comments powered by Disqus