program to dial land phone, enter password and record?
Linux command line:
linphone
includes a scriptable linphonec
command-line version. Starting linphonec
with the --pipe
option will create a socket in /tmp
that one can write to and read from.
It fulfills all your requirements and I've tested (for my own uses) all of them successfully:
- Calling via SIP,
- transmitting DTMF sequences,
- recording a call to file, and
- via parsing its output, you can see when the call finishes and quit the program.
You'd do a loop like this:
#!/bin/bash
socket=/tmp/linphonec-$(id -u)
filename=$HOME/record
number=123456789
passfile=$HOME/1234.wav
linphonec --pipe 2>&1 |
while read -r line
do
echo $line
case $line in
*Ready )
sleep 1
echo ">>> initializing"
for command in \
"soundcard use files" \
"record $filename" \
"call $number"
do
echo -n $command | nc -q 5 -U $socket
done
;;
*Call\ *\ with\ *\ connected. )
sleep 1
echo ">>> sending pass"
echo -n "play $passfile" | nc -q 5 -U $socket
;;
*Call\ *\ ended. )
sleep 1
echo ">>> quitting"
while echo -n quit | nc -q 5 -U $socket 2>&-
do
i=$(expr $i + 1)
if test $i -ge 5
then
echo $(basename $0): could not shut down linphonec >&2
exit 1
fi
sleep 2
done
echo ">>> END"
exit
;;
esac
done
This is not yet on optimal solution. Note that under >>> sending pass
, I'm playing a wav file instead of sending a DTMF sequence. linphone
is capable of the latter, but during my cursory fiddling I haven't yet found the right way to do so while sound in- and output is on file basis to allow recording.
Sadly, linphone documentation is sparse. I've had best results just starting linphonec
interactively and using the builtin help
.
Related videos on Youtube
Radek
Updated on September 18, 2022Comments
-
Radek almost 2 years
is there a program for Windows (or linux command line) platform that would do below from a command line?
- call a land phone number (using my SIP account)
- enter password
- record the call
- finishes after a period of time or after the other part hangs up?
-
Radek about 13 yearssounds really great. Could you give me some hint about the "via parsing its output, you can see when the call finishes and quit the program." I cannot grasp what it could mean. The rest be in readme or online help I guess.
-
Old Geezer almost 5 yearsThe credentials can be put inside the configured file specified with the
-c
option. The number to call can be specified with-s
. -
Old Geezer almost 5 years@peth In
while echo -n quit | nc -q 5 -U $socket 2&>-
, what condition evaluates to true/false? Also, what does2&>-
mean? For me, the expression evaluates to false but linphonec remains running. It's a pity the there is no option for linphonec to exit after a call hangs up. -
peth over 3 years@OldGeezer I don't know if the whole of this works anymore, but it relies on a) linphone removing its control socket when it shuts down and b)
nc
returning an error when it can't write to the socket. (2&>-
was supposed to read2>&-
which closes thestderr
output stream to suppress repeated output. It's purely cosmetic.) In other words, the loop repeatedly tells linphone to quit until it no longer listens.