Bob (EN)
Bob is a computer system for diverting a telephone number according to a schedule. Bob functions within the Dutch telephone infrastucture. Maybe it also functions abroad, but that hasn't been tested yet.
Bob 1.0 was developed for the Microsoft Windows platform, using Microsoft Access. Bob 1.0 has been retired. Bob 2.0 has been developed for Linux (Ubuntu Server). It works flawlessly and is incredibly simple to set up and maintain. This article is about Bob 2.0.
Requirements
Bob requires the following hardware:
- A computer capable of running Linux
- an analog telephone modem that functions under Linux. Usually, this limites the choice to external modems with serial connections. These are hard to find these days
- The modem needs to be connected to the telephone line that needs to be diverted
- Preferably: An internet connection for managing Bob remotely
Set-up
Bob's basic architecture is as follows:
- The open source communication program Kermit is used for dialing numbers through the modem
- A Kermit script dialresponder is located at /usr/bin. It takes as its argument the telephone number to which the connected telephone has to be diverted. dialresponder diverts the line to this number, waits a second, and subsequently dials the number belonging to the attached telephone line to alert the person to whom the number has been diverted of this.
- Through cron jobs (the Linux equivalent of Windows' Scheduled tasks), dialresponder is being invoked.
- When there is an internet connection, the computer can be reached through SSH (Secure Shell)
The remainder of this document details various aspects of Bob.
Dialresponder script
This is the original dialresponder script that does the actual diverting of the telephone line.
#!/usr/bin/kermit + set line /dev/ttyS0 set carrier-watch off set dial display on set dial timeout 1 output at*ncd dial *21*\%1# dial 0201234567890 exit
Some comments:
- It seems that the device (/dev/ttyS0 in the example) can change after a reboot and/or disconnection of the system. Sometimes, it seems to emerge as /dev/ttyS1. Probably best would be to make a symbolic link from the actual device to /dev/modem.
- As argument, the script takes a telephone number to which the lined needs to be diverted.
- As you can see, there are two dial-actions: The first to divert the telephone line (through the *21*-divertion service) and the second for dialing the number that needs to be diverted. This second call functions as a reminder to the person on call.
- The number 0201234567890 needs to be replaced with the actual number that is being diverted.
- For more on Kermit, especially about real time interacting with a modem (nice for debugging), see http://www.columbia.edu/kermit/.
- Before settling on Ubuntu Server as operating system for Bob 2.0, FreeBSD was briefly considered but it proved unpractical. With FreeBSD, the modem became available as device /dev/cuad0.
- Usually, modems check for the presence of a dial tone, and further, sometimes modems keep track of repeated failed calls. In some countries, such checks are imposed by legislation, to avoid modems endlessly phoning to wrong numbers. When a modem detects such a failure, numbers get blocked, and the modem replies with error codes like NO DIAL TONE (code 21) or worse: BLACKLISTED (code 34) or CALL DELAYED (code 3?). These checks by the modem can be avoided through specific extended Hayes commands. In the example above, the command is at*ncd (found in an obscure newgroup article). See http://tldp.org/HOWTO/Modem-HOWTO-8.html#ss8.5 for further details.
Here's a version that has been edited by someone else. I suspect that it is an improvement:
#!/usr/bin/kermit + set line /dev/ttyS1 set carrier-watch off set dial display on set dial timeout 10 #set dial ignore-dialtone on set modem command init-string AT&FX3E1V1\{13} set dial dial-command atDT,%s\{13} output at*ncd dial 0204567890 # End-of-shift notification dial *21*\%1# dial 0206256057 # beginning-of-shift notification exit
Log file
When a cron job gets executed, an entry is added to the cron log file. You can view log file lines that contain the word 'dialresponder' through:
cat /var/log/cron.log | grep dialresponder
Manage tasks
On Linux and Unix, tasks can be scheduled through the system program cron. It's the equivalent of Scheduled tasks in Windows. A task is called a cron job, and the list of all tasks is maintained in a cron file.
List cron jobs:
crontab -l
Edit cron jobs:
crontab -e
The computer starts the editor Nano for editing the cron file. At the bottom of the screen, you see several commands along with their abbreviations:
^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^ Cur Pos ^X Exit ^J Justify ^W Where Is ^V Next Page ^U UnCut text ^T To Spell
Of these, probably ^X Exit is the only relevant command. The ^ means the CTRL key. So, ^X means CTRL-X. You need this command for saving and exiting the cron file. After you press it, Nano asks for confirmation that you want to save it (Press y'). Subsequently, it asks for confirmation of the file name (press Enter).
SSH
When Bob runs on a computer that is connected to the internet, it can be approached through Secure Shell (SSH). For this, you need a SSH client on your local computer, like PuTTY. PuTTY can be downloaded from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.
To connect to Bob, you need the IP address of the computer it is running on, as well a login name and password.
When finished with PuTTY, exit it through:
exit
System time
When you add a new cron job, make sure that there is at least a whole minute between the current time and the new cron job. You can use the command
date
to see the current system time.
Enable booting without keyboard
I know it's obvious. Actually, it's too obvious, and therefore, I am prone to forget it. Whenever I come across a computer that cannot boot without keyboard (e.g., because no access to the BIOS-menu), I store a keyboard along with the computer
Installation procedure - October 2011 (1)
In October 2011, we installed and configured a computer for running Bob. this was probably the seventh time we did so. Here's what we did.
- Install Ubuntu Server 10.04 from cd;
- Update the installation:
sudo apt-get update
andsudo apt-get upgrade
- Install SSH:
sudo apt-get install openssh-server
- Install Kermit:
sudo apt-get install ckermit
- Retrieve correct debice-id: Get a list of likely devices:
dmesg | grab tty
- Retrieve correct device-id: Install Minicom:
sudo apt-get install minicom
- Retrieve correct device-id: Start Minicom --> CTRL-A Z --> cOnfigure Minicom --> set ttyS1 as device, Save as default, quit Minicom, start again, see if the lights react. So far, I think we only used devices ttyS0 and ttyS1, but I can't tell when to use one or the other.
- Create file dialresponder and copy the content from the dialresponder-chapter on this article to this file, and adapt modem device-id, if necessary. I place this file usually in /usr/bin, for this is already within $PATH, and that's easy for execution from cron jobs. Make the script executable through
chmod +x dialresponder
- Test the script. I usually start by phoning my mobile number
- Enable cron job logging: Remove comment sign concerning logging of cron jobs in /etc/rsyslog.d/50-default.conf
- Enable cron job logging: Restart rsyslog:
sudo restart rsyslog
Installation procedure - October 2011 (2)
Computer configuration
Let's now do it a bit quicker.
After installation, install additional packages through
sudo apt-get install minicom ckermit openssh-server
Identify modem device-id:
- Retrieve likely devices through
dmesg | grep tty
- Minicom --> cOnfigure --> set ttyS1 --> Exit --> Start again: Tjakka: Contact
Enable cron logging:
- remove comment mark in front of line that mentiones cron:
sudo vi /etc/rsyslog.d/50-default.conf
- Restart logging:
sudo restart rsyslog
Copy dialresponder script to /usr/bin/dialresponder, edit it to only dial my mobile number, and make executable through
sudo chmod +x /usr/bin/dialresponder
Connect a telephone line to the modem and test through
dialresponder
Create a test cronjob, e.g.:
45 15 * * * dialresponder
Check logging:
less /var/log/cron.log
Configure fixed IP address. See Netwerken (Linux) for details.
Installation
We had quit some trouble getting the computer actually to function within the network where it was supposed to work. A problem seemed to be caused by the computer not easily taking a new dynamic IP address, once it gets on another network.
Additionally: Enable booting without keyboard. I know it's obvious.
Suggestion for next time: Take the modem to the office, and get it to function there, together with the computer on which Bob is running. Alternatively, take a screen and keyboard to the desired place of operation: Without proper internet access, ssh won't function.