Search code examples
bashserial-portmodem

Send "hit enter" with Bash Script


I'm running some bash script to send AT commands to my modem. For the commands to run, it's necessary to hit "enter" (return) for the modem to "read" it. I have a looping, with a part like this:

echo AT+SBDWT=$number >/dev/ttyUSB0
xvkbd -text "\r"
echo AT+SBDIX >/dev/ttyUSB0
xvkbd -text "\r"
sleep 15
done

xvkbd was one solution I've came across, but it seems to be working just for the first time. With this script, I need to hit enter as many times as I send commands, but it's not working properly.

Thanks for your time


Solution

  • Sorry, I couldn't add a comment to ask you this question, but I want to see if i can help, so I am posting an answer.

    Instead of using xvkbd, doesn't

    echo -ne '\r' > /dev/ttyUSB0
    

    or

    echo -ne '\n' > /dev/ttyUSB0
    

    work?