Background
We have a handful of Cisco C40s that I'm trying to automate via bash (although I'd be open to alternatives). I need to log into it, dial an IP, get back the call ID that's returned, and then use that CallID to send a DTMF tone to the far end. I'm able to get about 90% of the way there but for some reason using SSH isn't returning all the text that's returned when using an interactive session.
Interactive Shell Sample:
login as: admin
Using keyboard-interactive authentication.
Password:
Welcome to XXX
TANDBERG Codec Release TC7.1.1.168aadf
SW Release Date: 2014-04-11
*r Login successful
OK
xConfiguration Audio Volume: 0
** end
OK
xCommand Dial Number: FAR_END_IP
OK
*r DialResult (status=OK):
CallId: 73
ConferenceId: 44
** end
Non-Interactive Shell Samples
Without ssh -T
or ssh -t -t
Options
This occurs where call-init-step1.txt contains the xConfiguration Audio Volume: 0
and xCommand Dial Number: FAR_END_IP
in addition to a bye
to hang up.
[user@controlserver C40]$ cat call-init-step1.txt | ssh admin@cisco_codec
Pseudo-terminal will not be allocated because stdin is not a terminal.
Welcome to XXX
TANDBERG Codec Release TC7.1.1.168aadf
SW Release Date: 2014-04-11
*r Login successful
OK
** end
OK
OK
What I'm missing here is the block with
*r DialResult (status=OK):
CallId: 73
ConferenceId: 44
** end
so that I can parse it for the CallID
and then use it to send the next commands.
With ssh -T
or ssh -t -t
Options
A few threads had suggested using ssh -T
or ssh -t -t
which in this case doesn't seem to help, below is the output.
[user@controlserver C40]$ cat call-init-step1.txt | ssh -T admin@cisco_codec
Welcome to XXX
TANDBERG Codec Release TC7.1.1.168aadf
SW Release Date: 2014-04-11
*r Login successful
OK
** end
OK
OK
And
[user@controlserver C40]$ cat call-init-step1.txt | ssh -t -t admin@cisco_codec
Welcome to XXX
TANDBERG Codec Release TC7.1.1.168aadf
SW Release Date: 2014-04-11
*r Login successful
OK
** end
OK
OK
The Question
Any insight in how to get the missing DialResult
block would be greatly appreciated.
Edit: I should also mention that ultimately the command cat call-init-step1.txt | ssh admin@cisco_codec
would get redirected to a file to be parsed further on in my script meaning it would probably look something like cat call-init-step1.txt | ssh -t -t admin@cisco_codec > results.txt
and then be parsed.
Edit 2: To frame what I'm working with the full API guide is found here
Edit 2.5: An attempt with expect
Per a suggestion from @MarkSetchell we went ahead and wrote a semi-functional expect script that looks like the following:
#!/usr/bin/expect
spawn ssh admin@cisco_codec
expect "*r Login successful"
send "xConfiguration Audio Volume: 0"
expect "OK"
send "xCommand Dial Number: FAR_END_IP"
expect "** end"
That resulted in the following:
[user@controlserver C40]$ expect expect-call
spawn ssh admin@cisco_codec
Welcome to XXX
TANDBERG Codec Release TC7.1.1.168aadf
SW Release Date: 2014-04-11
*r Login successful
OK
xConfiguration Audio Volume: 0xCommand Dial Number: FAR_END_IPxConfiguration Audio Volume: 0xCommand Dial Number: FAR_END_IP