linux - Sending modem AT command and parsing result -
i send at command modem using shell script , parse result in order verify if ok returned.
at=`echo -ne "at+cfun1=1\r\n" > /dev/ttyusb0 | cat /dev/ttyusb0` what best way parse at1 variable , extract "ok" or "error" otherwise ?
it absolutely possible send @ commands modem , capture output command line trying do, not using plain bash shell scripting. why wrote program atinout support scenarios ask about.
test following:
modem_device=/dev/ttyusb0 modem_output=`echo @ | atinout - $modem_device -` case $modem_output in *ok*) echo "hurray, modem , running :)" ;; *) echo "oh no! not working :(" ;; esac if intend parse output in more sophisticated way should save output file instead giving filename instead of last - , read that.
Comments
Post a Comment