Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
274 views
in Technique[技术] by (71.8m points)

php - Use AT command in shell script

I'm using gsm modem to send sms, via a terminal there's no problem but i want to write a shell script (called by php) and i want to know how insert AT command in.

Example :

  • call the script.sh
  • the script open minicom (sudo..)
  • type : AT+CMGS="num" + ENTER + "Message" + ctrl+Z and send the sms to the num.

Thank you Victor

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

For the time being1 I think your best option here is to use the programming language . It is written to monitor growing text output and support scenarios like

  1. Wait for the string "Username:" to appear in the output.
  2. Send the string "my_name".
  3. Wait for the string "Password:" to appear in the output.
  4. Send the string "my_secret_password".

Sending AT command and waiting for the response is very similar, so this is absolutely doable. When I worked at Ericsson we had a test suite written in expect that sent AT commands and parsed log files to run tests.


1 As a companion to my atinout program, I have started to write a program to send the command AT+CMGS and its payload correctly. But unless you are very, very patient you should not wait for this to be finished.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...