Skip to content

Latest commit

 

History

History
168 lines (138 loc) · 3.66 KB

bcmd-design.org

File metadata and controls

168 lines (138 loc) · 3.66 KB

The Design of bcmd

bcmd is a shell script that runs a command and emails the output to an email address.

It is a shell script.

A working local smtp server is required.

bcmd starts with a shebang.

bcmd saves the log file in /tmp by user name. It needs to know the user name.

bcmd takes two parameters. The t parameter takes the email address that the output will be sent to. The c parameter takes the command.

bcmd sets the output files, which include an email file and the command file. The email follows the structure of an email that sendmail would take. It includes a subject line, while the rest is the output from the command.

Echo the subject line to the email file. In the email body, echo the date. Run the command, of which the output is added to the email body.

Send the email.

Move the email and command files, so that five last histories are kep.

List the output files. Echo the current time before ending the program.

Put every piece together. Tangle it to ../bcmd.

../bcmd needs to be executable. The code below is executed, when this org document is exported, which sets ../bcmd to be executable.

chmod +x ../bcmd