Bob (EN)
Uit SlowTrainWiki
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.
Bob requires the following hardware:
- A computer capable of running Linux
- an analog telephone modem that functions under Linux
- The modem needs to be connected to the telephone line that needs to be diverted
- Preferably: An internet connection for managing Bob remotely
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. Chapters are in alphabetical order.
Inhoud |
Dialresponder script
This is the 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.
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.
