ttyecho
ttyecho copied to clipboard
How to pass commands with arguments?
Thank you for sharing ttyecho. How to pass i.e. sed to the ttyecho?
i.e.
sudo ttyecho /dev/ttyS001 sed -i '/....c\/.../' /etc/myconf
Just send the whole command as a single string including spaces separating the arguments. Keep in mind that you may need to escape the special characters.
In your case use this command. (-n added to insert the final newline)
sudo ttyecho -n /dev/ttyS001 "sed -i '/....c\\/.../' /etc/myconf"
You can test the escaping using printf %s\\n:
$ printf %s\\n "sed -i '/....c\\/.../' /etc/myconf"
sed -i '/....c\/.../' /etc/myconf
You should see the exact sequence of characters which you want to type in the other terminal. To see all the characters including invisible ones you can use for example od:
$ printf %s "sed -i '/....c\\/.../' /etc/myconf" | od -tax1
0000000 s e d sp - i sp ' / . . . . c \ /
73 65 64 20 2d 69 20 27 2f 2e 2e 2e 2e 63 5c 2f
0000020 . . . / ' sp / e t c / m y c o n
2e 2e 2e 2f 27 20 2f 65 74 63 2f 6d 79 63 6f 6e
0000040 f
66