streamkid.net

2008-07-26

Sample code how to use file descriptors in bash to send email.

bash mailer

Or, more of a how to use file descriptors in bash to send email, open pages, etc. It's not a complete mailer script, though it can send emails.

About /dev/tcp^

There isn't really any tcp device. If you build bash with net support, it recognises /dev/tcp and acts accordingly. It's a bash feature. To enable this feature in gentoo, you have to build bash with net use flag enabled.

File descriptors^

In bash, you use file descriptors to redirect output. You can read a very good article here, which covers most of what's used in the script below.

The script^

You can download the script from here. Right now, it can recognise responses only from a preset server. Perhaps if I ever need to, I'll set up response recognition, to make it work with every server, plus encryption support.