Sending shell script command keystrokes to a remote shell
Is it possible to make the script run when it shifts from normal mode to the interactive mode.
#/bash/bin
sudo gatttool -b 80:EA:CA:00:00:03 -I
# All these commands are typed in interactive mode
connect
while [ 1 ]; do
char_read_hnd 0x0030 > a.txt
done
exit 1
linux shell-script expect
add a comment |
Is it possible to make the script run when it shifts from normal mode to the interactive mode.
#/bash/bin
sudo gatttool -b 80:EA:CA:00:00:03 -I
# All these commands are typed in interactive mode
connect
while [ 1 ]; do
char_read_hnd 0x0030 > a.txt
done
exit 1
linux shell-script expect
add a comment |
Is it possible to make the script run when it shifts from normal mode to the interactive mode.
#/bash/bin
sudo gatttool -b 80:EA:CA:00:00:03 -I
# All these commands are typed in interactive mode
connect
while [ 1 ]; do
char_read_hnd 0x0030 > a.txt
done
exit 1
linux shell-script expect
Is it possible to make the script run when it shifts from normal mode to the interactive mode.
#/bash/bin
sudo gatttool -b 80:EA:CA:00:00:03 -I
# All these commands are typed in interactive mode
connect
while [ 1 ]; do
char_read_hnd 0x0030 > a.txt
done
exit 1
linux shell-script expect
linux shell-script expect
edited Oct 28 '15 at 13:41
Arthur2e5
922519
922519
asked Oct 28 '15 at 9:09
Ank KhandelwalAnk Khandelwal
1
1
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
are you looking for
sudo gatttool -b 80:EA:CA:00:00:03 -I <<EOF
# All these commands are entered in interactive mode
connect
while [ 1 ]; do
char_read_hnd 0x0030 > a.txt
done
exit 1
EOF
the syntax cmd <<EOF (lines ) EOF (on a line of its onw) is called a here doc.
more complicated tasks involving e.g. waiting for a prompt or a particular response from the remote host should be done with theexpectscripting language, or perl'sExpect.pmmodule or python'spexpect. Other languages also have similar expect-like libraries.
– cas
Oct 28 '15 at 9:34
@cas Yes <<EOF does the trick, but I have to wait for a particular message from remote host to execute the other commands. As I am new to scripting language, I will have to look into other scripting language.
– Ank Khandelwal
Oct 28 '15 at 9:53
add a comment |
If you need just write or read you can use one string command like this:
gatttool -i hci0 -b device=MAC --char-write-req -a handle=0x0001 -n value=0x0001
gatttool -i hci0 -b device=MAC --char-read -a handle=0x0001
I found it here: http://www.mathieupassenaud.fr/control-your-plugs-with-bluetooth-and-bash-scripts/.
To find more options see gatttool --help-all.
add a comment |
You can use expect for shell or pexpect for python.
I think you're searching for something like this:
https://www.torsten-traenkner.de/wissen/smarthome/heizung.php
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f239164%2fsending-shell-script-command-keystrokes-to-a-remote-shell%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
are you looking for
sudo gatttool -b 80:EA:CA:00:00:03 -I <<EOF
# All these commands are entered in interactive mode
connect
while [ 1 ]; do
char_read_hnd 0x0030 > a.txt
done
exit 1
EOF
the syntax cmd <<EOF (lines ) EOF (on a line of its onw) is called a here doc.
more complicated tasks involving e.g. waiting for a prompt or a particular response from the remote host should be done with theexpectscripting language, or perl'sExpect.pmmodule or python'spexpect. Other languages also have similar expect-like libraries.
– cas
Oct 28 '15 at 9:34
@cas Yes <<EOF does the trick, but I have to wait for a particular message from remote host to execute the other commands. As I am new to scripting language, I will have to look into other scripting language.
– Ank Khandelwal
Oct 28 '15 at 9:53
add a comment |
are you looking for
sudo gatttool -b 80:EA:CA:00:00:03 -I <<EOF
# All these commands are entered in interactive mode
connect
while [ 1 ]; do
char_read_hnd 0x0030 > a.txt
done
exit 1
EOF
the syntax cmd <<EOF (lines ) EOF (on a line of its onw) is called a here doc.
more complicated tasks involving e.g. waiting for a prompt or a particular response from the remote host should be done with theexpectscripting language, or perl'sExpect.pmmodule or python'spexpect. Other languages also have similar expect-like libraries.
– cas
Oct 28 '15 at 9:34
@cas Yes <<EOF does the trick, but I have to wait for a particular message from remote host to execute the other commands. As I am new to scripting language, I will have to look into other scripting language.
– Ank Khandelwal
Oct 28 '15 at 9:53
add a comment |
are you looking for
sudo gatttool -b 80:EA:CA:00:00:03 -I <<EOF
# All these commands are entered in interactive mode
connect
while [ 1 ]; do
char_read_hnd 0x0030 > a.txt
done
exit 1
EOF
the syntax cmd <<EOF (lines ) EOF (on a line of its onw) is called a here doc.
are you looking for
sudo gatttool -b 80:EA:CA:00:00:03 -I <<EOF
# All these commands are entered in interactive mode
connect
while [ 1 ]; do
char_read_hnd 0x0030 > a.txt
done
exit 1
EOF
the syntax cmd <<EOF (lines ) EOF (on a line of its onw) is called a here doc.
answered Oct 28 '15 at 9:12
ArchemarArchemar
20.2k93773
20.2k93773
more complicated tasks involving e.g. waiting for a prompt or a particular response from the remote host should be done with theexpectscripting language, or perl'sExpect.pmmodule or python'spexpect. Other languages also have similar expect-like libraries.
– cas
Oct 28 '15 at 9:34
@cas Yes <<EOF does the trick, but I have to wait for a particular message from remote host to execute the other commands. As I am new to scripting language, I will have to look into other scripting language.
– Ank Khandelwal
Oct 28 '15 at 9:53
add a comment |
more complicated tasks involving e.g. waiting for a prompt or a particular response from the remote host should be done with theexpectscripting language, or perl'sExpect.pmmodule or python'spexpect. Other languages also have similar expect-like libraries.
– cas
Oct 28 '15 at 9:34
@cas Yes <<EOF does the trick, but I have to wait for a particular message from remote host to execute the other commands. As I am new to scripting language, I will have to look into other scripting language.
– Ank Khandelwal
Oct 28 '15 at 9:53
more complicated tasks involving e.g. waiting for a prompt or a particular response from the remote host should be done with the
expect scripting language, or perl's Expect.pm module or python's pexpect. Other languages also have similar expect-like libraries.– cas
Oct 28 '15 at 9:34
more complicated tasks involving e.g. waiting for a prompt or a particular response from the remote host should be done with the
expect scripting language, or perl's Expect.pm module or python's pexpect. Other languages also have similar expect-like libraries.– cas
Oct 28 '15 at 9:34
@cas Yes <<EOF does the trick, but I have to wait for a particular message from remote host to execute the other commands. As I am new to scripting language, I will have to look into other scripting language.
– Ank Khandelwal
Oct 28 '15 at 9:53
@cas Yes <<EOF does the trick, but I have to wait for a particular message from remote host to execute the other commands. As I am new to scripting language, I will have to look into other scripting language.
– Ank Khandelwal
Oct 28 '15 at 9:53
add a comment |
If you need just write or read you can use one string command like this:
gatttool -i hci0 -b device=MAC --char-write-req -a handle=0x0001 -n value=0x0001
gatttool -i hci0 -b device=MAC --char-read -a handle=0x0001
I found it here: http://www.mathieupassenaud.fr/control-your-plugs-with-bluetooth-and-bash-scripts/.
To find more options see gatttool --help-all.
add a comment |
If you need just write or read you can use one string command like this:
gatttool -i hci0 -b device=MAC --char-write-req -a handle=0x0001 -n value=0x0001
gatttool -i hci0 -b device=MAC --char-read -a handle=0x0001
I found it here: http://www.mathieupassenaud.fr/control-your-plugs-with-bluetooth-and-bash-scripts/.
To find more options see gatttool --help-all.
add a comment |
If you need just write or read you can use one string command like this:
gatttool -i hci0 -b device=MAC --char-write-req -a handle=0x0001 -n value=0x0001
gatttool -i hci0 -b device=MAC --char-read -a handle=0x0001
I found it here: http://www.mathieupassenaud.fr/control-your-plugs-with-bluetooth-and-bash-scripts/.
To find more options see gatttool --help-all.
If you need just write or read you can use one string command like this:
gatttool -i hci0 -b device=MAC --char-write-req -a handle=0x0001 -n value=0x0001
gatttool -i hci0 -b device=MAC --char-read -a handle=0x0001
I found it here: http://www.mathieupassenaud.fr/control-your-plugs-with-bluetooth-and-bash-scripts/.
To find more options see gatttool --help-all.
answered Feb 17 '17 at 13:08
Herman Y.Herman Y.
113
113
add a comment |
add a comment |
You can use expect for shell or pexpect for python.
I think you're searching for something like this:
https://www.torsten-traenkner.de/wissen/smarthome/heizung.php
add a comment |
You can use expect for shell or pexpect for python.
I think you're searching for something like this:
https://www.torsten-traenkner.de/wissen/smarthome/heizung.php
add a comment |
You can use expect for shell or pexpect for python.
I think you're searching for something like this:
https://www.torsten-traenkner.de/wissen/smarthome/heizung.php
You can use expect for shell or pexpect for python.
I think you're searching for something like this:
https://www.torsten-traenkner.de/wissen/smarthome/heizung.php
answered Feb 22 at 7:17
rundekugelrundekugel
1012
1012
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f239164%2fsending-shell-script-command-keystrokes-to-a-remote-shell%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown