Hello,
I'm strugling with some redirecting and all help is apreciated.
The following program is working as expected, but the result of the AT command doesn't go to any file.
Thanks in advance for the help.
#!/bin/bash
modem=/dev/ttyUSB1
file=/root/imsi.txt
# print error to stderr and exit unsuccessfully
die() {
echo "$@" >&2
exit 1
}
/bin/date
# chat helper. try everything twice.
send_expect() {
chat -V ABORT ERROR '' "$@" '' || chat -V ABORT ERROR '' "$@" ''
}
# keep modem open, so CD doesn't go low and drop connection
# move terminal to FD3 to avoid redirects on everything else ...
exec 3<&1 >"$modem" <"$modem"
# setup modem options ...
stty -F /dev/ttyUSB1 9600 cs8 -parenb -cstopb
if ! [ -e "$modem" ]; then
die 'Modem not connected'
fi
if ! send_expect 'AT+GCLI?' 'OK'; then
die 'Modem not registered'
fi
cat "$file"
# give user idea of success
echo "done" >&3
The output of this program is something like
sh miniteste.sh
Tue 3 Dec 17:08:34 WET 2013
+GCLI: 18
4355,33e2c,29,44
4375,33e3c,26,38
4374,33e21,19,24
4373,33e47,18,23
4658,33e25,18,23
4353,33e17,18,22
4372,33e16,14,14
4359,33e54,13,13
4660,33e2a,11,13
4728,33e1a,13,12
4356,33e35,11,9
4713,33e1e,11,9
4357,33e3e,10,6
4354,33e22,9,5
4736,33e41,8,3
4729,33e3f,8,2
4720,33e45,6,-2
4712,33e50,6,-2
OKdone
My problem is that the text after the AT command doesn't show up on the results file, I tried redirecting at command level and doesn't show up.
Thanks for all the help
CLeitao