Bash program which is executed on child process of Node.js not show echo
Background
I'm working on node.js + react project.
I'm making automated deploy system on my ubuntu server which have my source.
So, I made webhook.js server and deploy.sh file.
webhook.js is for listening a message sended by github's webhook when I push some new commit and executing a deploy.sh bash program.
deploy.sh does git pull origin master
and restart my server.
webhook.js
const secret = 'xxxxxxxx';
let http = require('http');
let crypto = require('crypto');
const exec = require('child_process').exec;
http.createServer(function(req, res){
req.on('data', function(chunk){
let sig = "sha1=" + crypto.createHmac('sha1', secret).update(chunk.toString()).digest('hex');
if (req.headers['x-hub-signature'] == sig) {
deploy(res);
} else {
console.log('un matched');
}
});
res.end();
}).listen(8080);
function deploy(res){
exec('/home/rpf5573/nodewebhook/deploy.sh', function(err, stdout, stderr){
console.log('deploy.sh is called');
if (err) {
console.error(err);
res.writeHead(404);
return res.end();
}
res.writeHead(200);
res.end();
});
}
deploy.sh
cd /home/rpf5573/react-discovery-v2
echo "Pulling from Master"
git pull origin master
echo "Pulled successfully from master"
echo "Restarting server..."
npm restart-server
echo "Server restarted Successfully"
So, what's your problem?
my deploy.sh dosent show any echo
message. git pull origin master
is executed well, but only echo message not work !
How can I see the echo message?
Is this because deploy.sh is executed other shell?
node.js bash git
add a comment |
Background
I'm working on node.js + react project.
I'm making automated deploy system on my ubuntu server which have my source.
So, I made webhook.js server and deploy.sh file.
webhook.js is for listening a message sended by github's webhook when I push some new commit and executing a deploy.sh bash program.
deploy.sh does git pull origin master
and restart my server.
webhook.js
const secret = 'xxxxxxxx';
let http = require('http');
let crypto = require('crypto');
const exec = require('child_process').exec;
http.createServer(function(req, res){
req.on('data', function(chunk){
let sig = "sha1=" + crypto.createHmac('sha1', secret).update(chunk.toString()).digest('hex');
if (req.headers['x-hub-signature'] == sig) {
deploy(res);
} else {
console.log('un matched');
}
});
res.end();
}).listen(8080);
function deploy(res){
exec('/home/rpf5573/nodewebhook/deploy.sh', function(err, stdout, stderr){
console.log('deploy.sh is called');
if (err) {
console.error(err);
res.writeHead(404);
return res.end();
}
res.writeHead(200);
res.end();
});
}
deploy.sh
cd /home/rpf5573/react-discovery-v2
echo "Pulling from Master"
git pull origin master
echo "Pulled successfully from master"
echo "Restarting server..."
npm restart-server
echo "Server restarted Successfully"
So, what's your problem?
my deploy.sh dosent show any echo
message. git pull origin master
is executed well, but only echo message not work !
How can I see the echo message?
Is this because deploy.sh is executed other shell?
node.js bash git
2
You're not doing anything with the stdout or stderr results. Where do you expect them to be displayed?
– tripleee
Jan 2 at 7:02
2
Tangentially, diagnostic output should be sent to stderr, not stdout (echo "$0: message here" >&2
)
– tripleee
Jan 2 at 7:03
Which command do you actually manually run in your terminal?
– l0b0
Jan 2 at 7:04
@tripleee I want to see that message on my terminal. what is$0 and >&2
???
– Byeongin Yoon
Jan 2 at 7:11
@l0b0 I just runnode webhook.js
command manually and listening message from github webhook. And my child process will run deploy.sh program. Do I understand your question well?
– Byeongin Yoon
Jan 2 at 7:13
add a comment |
Background
I'm working on node.js + react project.
I'm making automated deploy system on my ubuntu server which have my source.
So, I made webhook.js server and deploy.sh file.
webhook.js is for listening a message sended by github's webhook when I push some new commit and executing a deploy.sh bash program.
deploy.sh does git pull origin master
and restart my server.
webhook.js
const secret = 'xxxxxxxx';
let http = require('http');
let crypto = require('crypto');
const exec = require('child_process').exec;
http.createServer(function(req, res){
req.on('data', function(chunk){
let sig = "sha1=" + crypto.createHmac('sha1', secret).update(chunk.toString()).digest('hex');
if (req.headers['x-hub-signature'] == sig) {
deploy(res);
} else {
console.log('un matched');
}
});
res.end();
}).listen(8080);
function deploy(res){
exec('/home/rpf5573/nodewebhook/deploy.sh', function(err, stdout, stderr){
console.log('deploy.sh is called');
if (err) {
console.error(err);
res.writeHead(404);
return res.end();
}
res.writeHead(200);
res.end();
});
}
deploy.sh
cd /home/rpf5573/react-discovery-v2
echo "Pulling from Master"
git pull origin master
echo "Pulled successfully from master"
echo "Restarting server..."
npm restart-server
echo "Server restarted Successfully"
So, what's your problem?
my deploy.sh dosent show any echo
message. git pull origin master
is executed well, but only echo message not work !
How can I see the echo message?
Is this because deploy.sh is executed other shell?
node.js bash git
Background
I'm working on node.js + react project.
I'm making automated deploy system on my ubuntu server which have my source.
So, I made webhook.js server and deploy.sh file.
webhook.js is for listening a message sended by github's webhook when I push some new commit and executing a deploy.sh bash program.
deploy.sh does git pull origin master
and restart my server.
webhook.js
const secret = 'xxxxxxxx';
let http = require('http');
let crypto = require('crypto');
const exec = require('child_process').exec;
http.createServer(function(req, res){
req.on('data', function(chunk){
let sig = "sha1=" + crypto.createHmac('sha1', secret).update(chunk.toString()).digest('hex');
if (req.headers['x-hub-signature'] == sig) {
deploy(res);
} else {
console.log('un matched');
}
});
res.end();
}).listen(8080);
function deploy(res){
exec('/home/rpf5573/nodewebhook/deploy.sh', function(err, stdout, stderr){
console.log('deploy.sh is called');
if (err) {
console.error(err);
res.writeHead(404);
return res.end();
}
res.writeHead(200);
res.end();
});
}
deploy.sh
cd /home/rpf5573/react-discovery-v2
echo "Pulling from Master"
git pull origin master
echo "Pulled successfully from master"
echo "Restarting server..."
npm restart-server
echo "Server restarted Successfully"
So, what's your problem?
my deploy.sh dosent show any echo
message. git pull origin master
is executed well, but only echo message not work !
How can I see the echo message?
Is this because deploy.sh is executed other shell?
node.js bash git
node.js bash git
asked Jan 2 at 6:55


Byeongin YoonByeongin Yoon
3861315
3861315
2
You're not doing anything with the stdout or stderr results. Where do you expect them to be displayed?
– tripleee
Jan 2 at 7:02
2
Tangentially, diagnostic output should be sent to stderr, not stdout (echo "$0: message here" >&2
)
– tripleee
Jan 2 at 7:03
Which command do you actually manually run in your terminal?
– l0b0
Jan 2 at 7:04
@tripleee I want to see that message on my terminal. what is$0 and >&2
???
– Byeongin Yoon
Jan 2 at 7:11
@l0b0 I just runnode webhook.js
command manually and listening message from github webhook. And my child process will run deploy.sh program. Do I understand your question well?
– Byeongin Yoon
Jan 2 at 7:13
add a comment |
2
You're not doing anything with the stdout or stderr results. Where do you expect them to be displayed?
– tripleee
Jan 2 at 7:02
2
Tangentially, diagnostic output should be sent to stderr, not stdout (echo "$0: message here" >&2
)
– tripleee
Jan 2 at 7:03
Which command do you actually manually run in your terminal?
– l0b0
Jan 2 at 7:04
@tripleee I want to see that message on my terminal. what is$0 and >&2
???
– Byeongin Yoon
Jan 2 at 7:11
@l0b0 I just runnode webhook.js
command manually and listening message from github webhook. And my child process will run deploy.sh program. Do I understand your question well?
– Byeongin Yoon
Jan 2 at 7:13
2
2
You're not doing anything with the stdout or stderr results. Where do you expect them to be displayed?
– tripleee
Jan 2 at 7:02
You're not doing anything with the stdout or stderr results. Where do you expect them to be displayed?
– tripleee
Jan 2 at 7:02
2
2
Tangentially, diagnostic output should be sent to stderr, not stdout (
echo "$0: message here" >&2
)– tripleee
Jan 2 at 7:03
Tangentially, diagnostic output should be sent to stderr, not stdout (
echo "$0: message here" >&2
)– tripleee
Jan 2 at 7:03
Which command do you actually manually run in your terminal?
– l0b0
Jan 2 at 7:04
Which command do you actually manually run in your terminal?
– l0b0
Jan 2 at 7:04
@tripleee I want to see that message on my terminal. what is
$0 and >&2
???– Byeongin Yoon
Jan 2 at 7:11
@tripleee I want to see that message on my terminal. what is
$0 and >&2
???– Byeongin Yoon
Jan 2 at 7:11
@l0b0 I just run
node webhook.js
command manually and listening message from github webhook. And my child process will run deploy.sh program. Do I understand your question well?– Byeongin Yoon
Jan 2 at 7:13
@l0b0 I just run
node webhook.js
command manually and listening message from github webhook. And my child process will run deploy.sh program. Do I understand your question well?– Byeongin Yoon
Jan 2 at 7:13
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fstackoverflow.com%2fquestions%2f54002392%2fbash-program-which-is-executed-on-child-process-of-node-js-not-show-echo%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
Thanks for contributing an answer to Stack Overflow!
- 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%2fstackoverflow.com%2fquestions%2f54002392%2fbash-program-which-is-executed-on-child-process-of-node-js-not-show-echo%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
2
You're not doing anything with the stdout or stderr results. Where do you expect them to be displayed?
– tripleee
Jan 2 at 7:02
2
Tangentially, diagnostic output should be sent to stderr, not stdout (
echo "$0: message here" >&2
)– tripleee
Jan 2 at 7:03
Which command do you actually manually run in your terminal?
– l0b0
Jan 2 at 7:04
@tripleee I want to see that message on my terminal. what is
$0 and >&2
???– Byeongin Yoon
Jan 2 at 7:11
@l0b0 I just run
node webhook.js
command manually and listening message from github webhook. And my child process will run deploy.sh program. Do I understand your question well?– Byeongin Yoon
Jan 2 at 7:13