Bash 输入 & ctrl-z 按键
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27310630/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bash enter & ctrl-z keypress
提问by rambutan
I have a command for minicom, send a SMS via modem with SSH/Putty , here is the command
我有一个 minicom 命令,通过调制解调器使用 SSH/Putty 发送短信,这是命令
AT^HCMGS="destination number"<press ENTER>
> SMS message <press CTRL + Z>
Command is successfully executed with minicom
使用 minicom 命令成功执行
I want to ask how to simulate press ENTER & CTRL+Z in bash Can I write script like this?
我想问一下如何在bash中模拟按ENTER & CTRL+Z 我可以写这样的脚本吗?
#!/bin/bash
echo -e -n "AT^HCMGS="888"(I don't know how to insert enter/return)" > /dev/ttyUSB0
echo -e -n "SMS message (I don't know how to insert ctrl+z)" > /dev/ttyUSB0
I want to integrate a program (motion linux) with this script in openWRT
我想在 openWRT 中集成一个程序(motion linux)和这个脚本
Thank you!
谢谢!
回答by user3719188
To send a message testto number +48333444555from shell:
从 shell向号码+48333444555发送消息测试:
echo -e 'AT+CMGS="+48333444555"^Mtest^Z' > /dev/ttyUSB0
Important:
重要:
- to get ^M You need press Ctrl+V and then Ctrl+M
- to get ^Z You need press Ctrl+V and then Ctrl+Z
- 要获得 ^M 你需要按 Ctrl+V 然后按 Ctrl+M
- 要获得 ^Z 您需要按 Ctrl+V 然后按 Ctrl+Z
回答by user3719188
$ man skill
:
$ man skill
:
SYNOPSIS
skill [signal] [options] expression
PROCESS SELECTION OPTIONS
-t, --tty tty
The next expression is a terminal (tty or pty).
EXAMPLES
skill -KILL -t /dev/pts/*
Kill users on PTY devices.
So it should be something like(can't verify it) : skill -STOP --tty /dev/ttyUSB0
所以它应该是这样的(无法验证): skill -STOP --tty /dev/ttyUSB0