# Sending AT-Commands without minicom [solved]

## dermund

Hi guys

I need to send two AT-command to my huawei 220 usb-modem in order to reactivate it since it's kind of buggy.

I have used minicom for this, talking over /dev/ttyUSB1 and I could just type AT+CFUN=0 ... AT+CFUN=1. And it worked perfect.

But now I want to put these two commands in a script for automation and I just can't figure out how. I won't do anything if I just do echo "AT+CFUN=0" > /dev/ttyUSB1.

I have also tried a chatscript with chat -v -f chatscript (chatscript is a oneliner: "AT+CFUN=0"). Nothing happens.

I've found nothing useful on the web. Maybe it works over chat, but I've got no experience with this. Please help.Last edited by dermund on Sat Nov 17, 2007 4:28 am; edited 1 time in total

----------

## Kosmas

Hi,

   chat utility is the best way to do it with a script. You just have to create a correct chat script file. What you put in the chat script is not just what you want to send to the modem but also what the modem responds. An example of sending what you want is

```
"" "AT+CFUN=0"

"OK" "AT+CFUN=1"

"OK"

```

and run chat -v -f /somewere/chatscript

This should do the trick. Keep in mind that in the chat script the first column is the responses from the modem and the second the commands you want to write.

Hope I gave you a hint.

Kosmas.

----------

## dermund

Hey thanks Kosmas for your quick response!

I changed the script like you said, but the reaction from the modem is still nothing and chat prog claims my console about 15 secounds and locks it...

In minicom I get an "OK" for "AT+CFUN=0" in return - but also more stuff like "^SRVST:0" "^MODE:0,0".

But writing "OK" as answer into the chatscript should be sufficent, what do you think?

Btw: How does "chat" know which device it should connect to?

----------

## Kosmas

OOPS!!! YOu should redirect the chat script to the modem device! Sorry for the mix-up.

----------

## dermund

chatscript:

```
"" "AT+CFUN=0"

"OK"

```

```
cat /etc/chatscripts/cfun0 > /dev/ttyUSB1
```

 doesn't work either...   :Crying or Very sad: 

----------

## dermund

ok I got it, it works!

```
echo -ne "AT+CFUN=1\r" > /dev/ttyUSB1
```

Obviously he wanted a carriage return.

Thanks for putting me in the right direction.

----------

## Kosmas

Glad I could say something to make you solve it. I hope I gave you the right info so that you could save some time. Nevertheless, solved is good enough!  :Smile: 

----------

