How to send SMS from Mac terminal via GSM modem?

一世执手 提交于 2020-01-24 11:44:07

问题


I have Mio A701 communicator that I would like to use as GSM modem for sending SMS from my Mac.

What I've found so far is that one just can send an AT commands directly from terminal to special ports like /dev/ttyUSB0 if modem is connected via USB port or /dev/rfcomm0 if connection is handled via bluetooth. My problem is that when I try to issue a command I get a "permission denied" response:

"AT+CMGS=test\r" > /dev/ttyUSB0
-bash: /dev/ttyUSB0: Permission denied

Also "ls /dev" shows that neither ttyUSB0 nor rfcomm0 files are present there so I can't update permissions on these files.

Any help would be greatly appreciated, thanks in advance.

Update: problem is solved.
First of all Mio A701 appears to be wrong choice since it does not support AT commands for sending SMS.

This PHP code works fine with Nokia 3310c connected via bluetooth:

$number="<phone number in international format with + sign>";
$message="Hello World\ntest"; // as far as I've tested \n successfully turns into a line break in SMS on Mio, Nokia and Alcatel phones
$port="/dev/tty.phone"; // this path was set in "Mac preferences" -> bluetooth -> "configure ports" for selected device


if($fd = fopen($port, 'a')) {
    fwrite($fd, "AT+CMGF=1\r"); // text mode for SMS
    sleep(2);
    fwrite($fd, "AT+CMGS=\"$number\"\r");
    sleep(2);
    fwrite($fd, "$message\032");
    sleep(2);
    $fh = null;
} else
    echo "Phone unreachable";

回答1:


best way to send sms and ussd messages is to install smstools3 (not smstools) and build on the sample scripts.




回答2:


Try smsd utility from smstools package, hope it will help



来源:https://stackoverflow.com/questions/2115904/how-to-send-sms-from-mac-terminal-via-gsm-modem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!