Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ltratt/cmdseq
Execute interleaved sequences of commands
https://github.com/ltratt/cmdseq
Last synced: 24 days ago
JSON representation
Execute interleaved sequences of commands
- Host: GitHub
- URL: https://github.com/ltratt/cmdseq
- Owner: ltratt
- License: other
- Created: 2016-01-01T15:01:02.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-12-20T08:53:15.000Z (about 3 years ago)
- Last Synced: 2024-11-02T09:42:20.910Z (2 months ago)
- Language: Shell
- Homepage: https://tratt.net/laurie/src/cmdseq/
- Size: 10.7 KB
- Stars: 2
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# cmdseq
## Overview
`cmdseq` allows users to execute interleaved sequences of commands. Assuming the
same counts and commands, on each execution cmdseq executes one of the
commands, cycling through the sequence and wrapping back to the beginning when
it is complete. For example, consider the following sequence:```
$ cmdseq 2 "echo cmd1" 1 "echo cmd2"
cmd1
$ cmdseq 2 "echo cmd1" 1 "echo cmd2"
cmd1
$ cmdseq 2 "echo cmd1" 1 "echo cmd2"
cmd2
$ cmdseq 2 "echo cmd1" 1 "echo cmd2"
cmd1
````cmdseq` can be useful for integrating with tools such as cron. For example, if
one is automatically synchronising large directories, one can set up a cron job
which usually performs a quick synchronisation, occasionally performing a slow
synchronisation:```
$ crontab -l
*/9 * * * * cmdseq 200 "sync quick" 1 "sync full"
```## Usage
The command-line arguments are as follows:
```
cmdseq [-d ] [... ]
```Where:
* `-d ` is a directory used to store command sequence cookies. It
defaults to `/tmp`.
* `` is an integer number of times cmd1 will be executed.
* is a command to be executed. If the command has options, it should be
surrounded by quote marks.`cmdseq` exits with the exit code of whichever cmd it ran.
## Security considerations
Since `cmdseq` does not stay in memory after the child command has completed,
it needs a way of storing its current position in the command sequence. It thus
stores a single integer in a cookie file (under `/tmp/` by default). The cookie
file's name is derived from a hash of the commands involved: although there can
be no guarantee of uniqueness, in practise multiple different command sequences
can be safely used. However, if an attacker can interfere with the cookie file
(which is marked user read/write only), they can prevent parts of the command
sequence from ever being run (e.g. by continually writing `0` to the cookie
file). Depending on your threat model you may thus not wish to use `cmdseq` for
security critical purposes.## More information
More information about cmdseq can be found at its webpage:
http://tratt.net/laurie/src/cmdseq/