Simple server that triggers script and responds
I need to have a server running that can:
- Take rest call. It triggers a script when a call is made
- The script checks if database is running or not.
- If running then reply back to client as
Success
else reply back as
failure
I do not wish to use apache or any other major web server. Even simple scripts running on port will do. I am aware of python -m SimpleHTTPServer
but I guess it only provides file access.
I can write a simple Java program that runs on a port and replies, but I am looking some simple solution
shell scripting webserver http
add a comment |
I need to have a server running that can:
- Take rest call. It triggers a script when a call is made
- The script checks if database is running or not.
- If running then reply back to client as
Success
else reply back as
failure
I do not wish to use apache or any other major web server. Even simple scripts running on port will do. I am aware of python -m SimpleHTTPServer
but I guess it only provides file access.
I can write a simple Java program that runs on a port and replies, but I am looking some simple solution
shell scripting webserver http
add a comment |
I need to have a server running that can:
- Take rest call. It triggers a script when a call is made
- The script checks if database is running or not.
- If running then reply back to client as
Success
else reply back as
failure
I do not wish to use apache or any other major web server. Even simple scripts running on port will do. I am aware of python -m SimpleHTTPServer
but I guess it only provides file access.
I can write a simple Java program that runs on a port and replies, but I am looking some simple solution
shell scripting webserver http
I need to have a server running that can:
- Take rest call. It triggers a script when a call is made
- The script checks if database is running or not.
- If running then reply back to client as
Success
else reply back as
failure
I do not wish to use apache or any other major web server. Even simple scripts running on port will do. I am aware of python -m SimpleHTTPServer
but I guess it only provides file access.
I can write a simple Java program that runs on a port and replies, but I am looking some simple solution
shell scripting webserver http
shell scripting webserver http
edited 2 hours ago
Rui F Ribeiro
41.5k1483140
41.5k1483140
asked Jun 26 '14 at 9:25
JatinJatin
11113
11113
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
One of the more trivial services I can imagine is to run one from xinetd. That has the advantage that xinetd itself is relatively light-weight but will still handle all the networking stuff for you including logging and security restrictions such as request limiting, TCP-wrappers etc.
Install xinetd, when it is not already installed and define a custom service like /etc/xinetd.d/helloworld
:
service helloworld
{
disable = no
port = 1234
socket_type = stream
protocol = tcp
wait = no
user = nobody
server = /usr/local/bin/hello-world.sh
server_args = test
instances = 1
type = unlisted
}
Reload/restart xinetd and you can test with a telnet localhost 1234
.
The manual page man xinetd.conf
has a pretty good description of the options available.
add a comment |
I would do that in BASH with the help of some simple nc
commands:
#!/bin/bash
nc -k -l -p PORT > tempfile
while true
do
if cat tempfile | grep request;
then
# Execute checker script
# Reply back with nc
: > tempfile # Clear tempfile
fi
sleep 1
done
This would require setting up the client with nc
as well. Maybe setting up an nc
listen command on the client is also required to receive the Success reply.
This script is far from complete, and you should also write the client for it, but it might give you some ideas.
The basic thing here is the use of nc
. With the help of it, you can set up simple client-server architectures.
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%2f139311%2fsimple-server-that-triggers-script-and-responds%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
One of the more trivial services I can imagine is to run one from xinetd. That has the advantage that xinetd itself is relatively light-weight but will still handle all the networking stuff for you including logging and security restrictions such as request limiting, TCP-wrappers etc.
Install xinetd, when it is not already installed and define a custom service like /etc/xinetd.d/helloworld
:
service helloworld
{
disable = no
port = 1234
socket_type = stream
protocol = tcp
wait = no
user = nobody
server = /usr/local/bin/hello-world.sh
server_args = test
instances = 1
type = unlisted
}
Reload/restart xinetd and you can test with a telnet localhost 1234
.
The manual page man xinetd.conf
has a pretty good description of the options available.
add a comment |
One of the more trivial services I can imagine is to run one from xinetd. That has the advantage that xinetd itself is relatively light-weight but will still handle all the networking stuff for you including logging and security restrictions such as request limiting, TCP-wrappers etc.
Install xinetd, when it is not already installed and define a custom service like /etc/xinetd.d/helloworld
:
service helloworld
{
disable = no
port = 1234
socket_type = stream
protocol = tcp
wait = no
user = nobody
server = /usr/local/bin/hello-world.sh
server_args = test
instances = 1
type = unlisted
}
Reload/restart xinetd and you can test with a telnet localhost 1234
.
The manual page man xinetd.conf
has a pretty good description of the options available.
add a comment |
One of the more trivial services I can imagine is to run one from xinetd. That has the advantage that xinetd itself is relatively light-weight but will still handle all the networking stuff for you including logging and security restrictions such as request limiting, TCP-wrappers etc.
Install xinetd, when it is not already installed and define a custom service like /etc/xinetd.d/helloworld
:
service helloworld
{
disable = no
port = 1234
socket_type = stream
protocol = tcp
wait = no
user = nobody
server = /usr/local/bin/hello-world.sh
server_args = test
instances = 1
type = unlisted
}
Reload/restart xinetd and you can test with a telnet localhost 1234
.
The manual page man xinetd.conf
has a pretty good description of the options available.
One of the more trivial services I can imagine is to run one from xinetd. That has the advantage that xinetd itself is relatively light-weight but will still handle all the networking stuff for you including logging and security restrictions such as request limiting, TCP-wrappers etc.
Install xinetd, when it is not already installed and define a custom service like /etc/xinetd.d/helloworld
:
service helloworld
{
disable = no
port = 1234
socket_type = stream
protocol = tcp
wait = no
user = nobody
server = /usr/local/bin/hello-world.sh
server_args = test
instances = 1
type = unlisted
}
Reload/restart xinetd and you can test with a telnet localhost 1234
.
The manual page man xinetd.conf
has a pretty good description of the options available.
answered Jun 26 '14 at 12:45
HBruijnHBruijn
5,6161527
5,6161527
add a comment |
add a comment |
I would do that in BASH with the help of some simple nc
commands:
#!/bin/bash
nc -k -l -p PORT > tempfile
while true
do
if cat tempfile | grep request;
then
# Execute checker script
# Reply back with nc
: > tempfile # Clear tempfile
fi
sleep 1
done
This would require setting up the client with nc
as well. Maybe setting up an nc
listen command on the client is also required to receive the Success reply.
This script is far from complete, and you should also write the client for it, but it might give you some ideas.
The basic thing here is the use of nc
. With the help of it, you can set up simple client-server architectures.
add a comment |
I would do that in BASH with the help of some simple nc
commands:
#!/bin/bash
nc -k -l -p PORT > tempfile
while true
do
if cat tempfile | grep request;
then
# Execute checker script
# Reply back with nc
: > tempfile # Clear tempfile
fi
sleep 1
done
This would require setting up the client with nc
as well. Maybe setting up an nc
listen command on the client is also required to receive the Success reply.
This script is far from complete, and you should also write the client for it, but it might give you some ideas.
The basic thing here is the use of nc
. With the help of it, you can set up simple client-server architectures.
add a comment |
I would do that in BASH with the help of some simple nc
commands:
#!/bin/bash
nc -k -l -p PORT > tempfile
while true
do
if cat tempfile | grep request;
then
# Execute checker script
# Reply back with nc
: > tempfile # Clear tempfile
fi
sleep 1
done
This would require setting up the client with nc
as well. Maybe setting up an nc
listen command on the client is also required to receive the Success reply.
This script is far from complete, and you should also write the client for it, but it might give you some ideas.
The basic thing here is the use of nc
. With the help of it, you can set up simple client-server architectures.
I would do that in BASH with the help of some simple nc
commands:
#!/bin/bash
nc -k -l -p PORT > tempfile
while true
do
if cat tempfile | grep request;
then
# Execute checker script
# Reply back with nc
: > tempfile # Clear tempfile
fi
sleep 1
done
This would require setting up the client with nc
as well. Maybe setting up an nc
listen command on the client is also required to receive the Success reply.
This script is far from complete, and you should also write the client for it, but it might give you some ideas.
The basic thing here is the use of nc
. With the help of it, you can set up simple client-server architectures.
answered Jun 26 '14 at 10:02
psimonpsimon
967726
967726
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%2f139311%2fsimple-server-that-triggers-script-and-responds%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