How can I receive phone calls on a Linux server and script stuff depending on the numbers pressed?

I live in France and the ISP I've subscribed to provides a regular phone line along with my Internet connection. Here's a simple schema of my setup:

schema

Since I don't use this phone line I would like to switch the regular phone with a computer (preferably running Linux) where I could receive/handle calls programatically. For example, execute a shell script if I press 2, that kind of thing.

How can I receive phone calls on a Linux server and script stuff depending on the numbers pressed?


Asterisk is free and a simple FXO/FXS adapter with 1 port like you need won't cost $400. Try looking for linksys SPA3102 for example and an example config. You don't need to buy expensive multi-ports internal cards.

Why don't you go SIP and need no adaptor, only the internet conection your BOX delivers?

With Sip, you will receive the call for free if you have an online number. You can open a pre-paid account so if you only receive calls, you won't pay anything for the calls and you will use your credits only if you place calls. A lot of providers have this option. As an example, I use callcentric not free for online numbers but a few providers have this option free (I used voxalot for a long time before but it is closed now).

The caller may have to pay for a regular phone call. you can use sip services like sipbroker to be reachable from multiple sip providers for free for the caller if he uses one of the associated sip providers and paying only for a local regular calls on most big cities around the world for free. There are many sip providers that can supply you with a phone number almost where you want (most for a fee) so the callers pay only for local calls (similar to skype online numbers).


You might try running Asterisk, which is:

Asterisk is an open source framework for building communications applications. Asterisk turns an ordinary computer into a communications server. Asterisk powers IP PBX systems, VoIP gateways, conference servers and more. It is used by small businesses, large businesses, call centers, carriers and governments worldwide. Asterisk is free and open source.

Beginning Asterisk documentation can be found here. Wikipedia entry is here.


http://pbxinaflash.net/

As mentioned, it uses Asterisk, but makes it pretty easy.

There site has a large variety of tutorials, step by step instructions, and you can be up and running very inexpensively.