Pesky BASH script bugBash regex string manipulation bugBash script errorbash script - loop functionshell...
A question regarding using the definite article
In the time of the mishna, were there Jewish cities without courts?
Asahi Dry Black beer can
Reverse the word in a string with the same order in javascript
"ne paelici suspectaretur" (Tacitus)
How can Republicans who favour free markets, consistently express anger when they don't like the outcome of that choice?
When did stoichiometry begin to be taught in U.S. high schools?
Binary Numbers Magic Trick
What does "rf" mean in "rfkill"?
In gnome-terminal only 2 out of 3 zoom keys work
Lock in SQL Server and Oracle
What is the difference between `a[bc]d` (brackets) and `a{b,c}d` (braces)?
Is it possible to Ready a spell to be cast just before the start of your next turn by having the trigger be an ally's attack?
How does a Swashbuckler rogue "fight with two weapons while safely darting away"?
How to back up a running remote server?
Stark VS Thanos
Illegal assignment from SObject to Contact
Find the coordinate of two line segments that are perpendicular
Pulling the rope with one hand is as heavy as with two hands?
Any examples of headwear for races with animal ears?
Single Colour Mastermind Problem
Did Henry V’s archers at Agincourt fight with no pants / breeches on because of dysentery?
Need help understanding harmonic series and intervals
Is GOCE a satellite or aircraft?
Pesky BASH script bug
Bash regex string manipulation bugBash script errorbash script - loop functionshell script with interesting bugPunctuation in bash scriptWord count bash scriptBash script won't runhave I found a bug in BASH?Daemonizing a bash scriptconvert arguments in bash script
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I am using the following short BASH script running on a Raspberry PI 3B to monitor port 11005 for 1 and 0 strings on a PC within my network - it toggles a GPIO output to key an amateur radio morse code transmitter. After displaying "Start listening on Port 11005, I get the error message
morse2.sh 36: morse2.sh: Syntax error: "(" unexpected.
I have tried a bunch of fixes - none work. Also, why does this script need nmap
to run? I have nmap
installed on the Raspberry pi - seems to run well.
#!/bin/bash
#be sure you have already installed nmap on your PI
PORT=11005
CW_PIN=25
echo "Start listening on port $PORT ..."
while read line
do
#echo $line
#echo $line | od -An -t uC
cmd=${line:0:1}
#echo $cmd
#echo $cmd | od -An -t uC
case "$cmd" in
0) #echo "000"
gpio write $CW_PIN 0
;;
1) #echo "111"
gpio write $CW_PIN 1
;;
3) echo "Going to stop listener ..."
break
;;
*) #echo "unknown cmd"
;;
esac
done < <((echo "Welcome. Please give me one of the following commands: 0 | 1 | 3") | ncat -k -l $PORT)
echo "... listener stopped."
exit 0
bash shell-script
New contributor
add a comment |
I am using the following short BASH script running on a Raspberry PI 3B to monitor port 11005 for 1 and 0 strings on a PC within my network - it toggles a GPIO output to key an amateur radio morse code transmitter. After displaying "Start listening on Port 11005, I get the error message
morse2.sh 36: morse2.sh: Syntax error: "(" unexpected.
I have tried a bunch of fixes - none work. Also, why does this script need nmap
to run? I have nmap
installed on the Raspberry pi - seems to run well.
#!/bin/bash
#be sure you have already installed nmap on your PI
PORT=11005
CW_PIN=25
echo "Start listening on port $PORT ..."
while read line
do
#echo $line
#echo $line | od -An -t uC
cmd=${line:0:1}
#echo $cmd
#echo $cmd | od -An -t uC
case "$cmd" in
0) #echo "000"
gpio write $CW_PIN 0
;;
1) #echo "111"
gpio write $CW_PIN 1
;;
3) echo "Going to stop listener ..."
break
;;
*) #echo "unknown cmd"
;;
esac
done < <((echo "Welcome. Please give me one of the following commands: 0 | 1 | 3") | ncat -k -l $PORT)
echo "... listener stopped."
exit 0
bash shell-script
New contributor
Where do I begin? (1) Does it actually say “morse2.sh
” twice in the error message? (2) Have you posted the complete script (i.e., the one that got that error message)? (3) When you edit the script, which one is line 36? (4) “Also, why does this script need nmap to run?” Because it usesnmap
. Or is your question something more subtle than that?
– Scott
2 hours ago
add a comment |
I am using the following short BASH script running on a Raspberry PI 3B to monitor port 11005 for 1 and 0 strings on a PC within my network - it toggles a GPIO output to key an amateur radio morse code transmitter. After displaying "Start listening on Port 11005, I get the error message
morse2.sh 36: morse2.sh: Syntax error: "(" unexpected.
I have tried a bunch of fixes - none work. Also, why does this script need nmap
to run? I have nmap
installed on the Raspberry pi - seems to run well.
#!/bin/bash
#be sure you have already installed nmap on your PI
PORT=11005
CW_PIN=25
echo "Start listening on port $PORT ..."
while read line
do
#echo $line
#echo $line | od -An -t uC
cmd=${line:0:1}
#echo $cmd
#echo $cmd | od -An -t uC
case "$cmd" in
0) #echo "000"
gpio write $CW_PIN 0
;;
1) #echo "111"
gpio write $CW_PIN 1
;;
3) echo "Going to stop listener ..."
break
;;
*) #echo "unknown cmd"
;;
esac
done < <((echo "Welcome. Please give me one of the following commands: 0 | 1 | 3") | ncat -k -l $PORT)
echo "... listener stopped."
exit 0
bash shell-script
New contributor
I am using the following short BASH script running on a Raspberry PI 3B to monitor port 11005 for 1 and 0 strings on a PC within my network - it toggles a GPIO output to key an amateur radio morse code transmitter. After displaying "Start listening on Port 11005, I get the error message
morse2.sh 36: morse2.sh: Syntax error: "(" unexpected.
I have tried a bunch of fixes - none work. Also, why does this script need nmap
to run? I have nmap
installed on the Raspberry pi - seems to run well.
#!/bin/bash
#be sure you have already installed nmap on your PI
PORT=11005
CW_PIN=25
echo "Start listening on port $PORT ..."
while read line
do
#echo $line
#echo $line | od -An -t uC
cmd=${line:0:1}
#echo $cmd
#echo $cmd | od -An -t uC
case "$cmd" in
0) #echo "000"
gpio write $CW_PIN 0
;;
1) #echo "111"
gpio write $CW_PIN 1
;;
3) echo "Going to stop listener ..."
break
;;
*) #echo "unknown cmd"
;;
esac
done < <((echo "Welcome. Please give me one of the following commands: 0 | 1 | 3") | ncat -k -l $PORT)
echo "... listener stopped."
exit 0
bash shell-script
bash shell-script
New contributor
New contributor
edited 1 hour ago
αғsнιη
17.8k103271
17.8k103271
New contributor
asked 2 hours ago
SteveWSteveW
11
11
New contributor
New contributor
Where do I begin? (1) Does it actually say “morse2.sh
” twice in the error message? (2) Have you posted the complete script (i.e., the one that got that error message)? (3) When you edit the script, which one is line 36? (4) “Also, why does this script need nmap to run?” Because it usesnmap
. Or is your question something more subtle than that?
– Scott
2 hours ago
add a comment |
Where do I begin? (1) Does it actually say “morse2.sh
” twice in the error message? (2) Have you posted the complete script (i.e., the one that got that error message)? (3) When you edit the script, which one is line 36? (4) “Also, why does this script need nmap to run?” Because it usesnmap
. Or is your question something more subtle than that?
– Scott
2 hours ago
Where do I begin? (1) Does it actually say “
morse2.sh
” twice in the error message? (2) Have you posted the complete script (i.e., the one that got that error message)? (3) When you edit the script, which one is line 36? (4) “Also, why does this script need nmap to run?” Because it uses nmap
. Or is your question something more subtle than that?– Scott
2 hours ago
Where do I begin? (1) Does it actually say “
morse2.sh
” twice in the error message? (2) Have you posted the complete script (i.e., the one that got that error message)? (3) When you edit the script, which one is line 36? (4) “Also, why does this script need nmap to run?” Because it uses nmap
. Or is your question something more subtle than that?– Scott
2 hours ago
add a comment |
0
active
oldest
votes
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
});
}
});
SteveW is a new contributor. Be nice, and check out our Code of Conduct.
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%2f516073%2fpesky-bash-script-bug%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
SteveW is a new contributor. Be nice, and check out our Code of Conduct.
SteveW is a new contributor. Be nice, and check out our Code of Conduct.
SteveW is a new contributor. Be nice, and check out our Code of Conduct.
SteveW is a new contributor. Be nice, and check out our Code of Conduct.
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%2f516073%2fpesky-bash-script-bug%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
Where do I begin? (1) Does it actually say “
morse2.sh
” twice in the error message? (2) Have you posted the complete script (i.e., the one that got that error message)? (3) When you edit the script, which one is line 36? (4) “Also, why does this script need nmap to run?” Because it usesnmap
. Or is your question something more subtle than that?– Scott
2 hours ago