Pipe/send command to process running on nohup that accepts input from STDIN
I have a program that I run using nohup program &. This program accepts input from STDIN. Is there any way to send text to the STDIN of a program that is running via nohup?
This is on FreeBSD running bash. I would like to see how this is done on linux as well.
pipe nohup
add a comment |
I have a program that I run using nohup program &. This program accepts input from STDIN. Is there any way to send text to the STDIN of a program that is running via nohup?
This is on FreeBSD running bash. I would like to see how this is done on linux as well.
pipe nohup
Linux (which)? Unix (which)? OS X? AmigaOS? It probably wouldn't hurt to say which shell. Bash? Bourne? Korn? C? Z? Fish?
– Dennis Williamson
Dec 21 '10 at 18:45
Sorry about that. Updated the question.
– vivin
Dec 21 '10 at 18:54
add a comment |
I have a program that I run using nohup program &. This program accepts input from STDIN. Is there any way to send text to the STDIN of a program that is running via nohup?
This is on FreeBSD running bash. I would like to see how this is done on linux as well.
pipe nohup
I have a program that I run using nohup program &. This program accepts input from STDIN. Is there any way to send text to the STDIN of a program that is running via nohup?
This is on FreeBSD running bash. I would like to see how this is done on linux as well.
pipe nohup
pipe nohup
edited Dec 21 '10 at 18:54
asked Dec 21 '10 at 18:41
vivin
7561615
7561615
Linux (which)? Unix (which)? OS X? AmigaOS? It probably wouldn't hurt to say which shell. Bash? Bourne? Korn? C? Z? Fish?
– Dennis Williamson
Dec 21 '10 at 18:45
Sorry about that. Updated the question.
– vivin
Dec 21 '10 at 18:54
add a comment |
Linux (which)? Unix (which)? OS X? AmigaOS? It probably wouldn't hurt to say which shell. Bash? Bourne? Korn? C? Z? Fish?
– Dennis Williamson
Dec 21 '10 at 18:45
Sorry about that. Updated the question.
– vivin
Dec 21 '10 at 18:54
Linux (which)? Unix (which)? OS X? AmigaOS? It probably wouldn't hurt to say which shell. Bash? Bourne? Korn? C? Z? Fish?
– Dennis Williamson
Dec 21 '10 at 18:45
Linux (which)? Unix (which)? OS X? AmigaOS? It probably wouldn't hurt to say which shell. Bash? Bourne? Korn? C? Z? Fish?
– Dennis Williamson
Dec 21 '10 at 18:45
Sorry about that. Updated the question.
– vivin
Dec 21 '10 at 18:54
Sorry about that. Updated the question.
– vivin
Dec 21 '10 at 18:54
add a comment |
1 Answer
1
active
oldest
votes
nohup runs the program with standard input redirected from /dev/null (assuming that you didn't redirect the nohup command itself). So no, you can't send input to this program.
If you want to send input to the program, redirect the input when you start it:
nohup program <input-file.txt & # input from a file
nohup data-producer | nohup program & # input from another program
mkfifo program.pipe; nohup program <program.pipe & # input from a named pipe, feed it what you want later
(Actually, it may be possible to reconnect the program's standard input to another source, by using ptrace, i.e. a debugger or other hack. This could crash the program if it keeps track where its input is from. See How can I pause up a running process over ssh, disown it, associate it to a new screen shell and unpause it?; there are other questions on the SE network on this topic.)
Won't data-producer get killed?
– wliao
Dec 5 at 18:00
1
@wliao Indeed. I've addednohupin front of it as well, thanks.
– Gilles
Dec 5 at 19:55
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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%2fsuperuser.com%2fquestions%2f224599%2fpipe-send-command-to-process-running-on-nohup-that-accepts-input-from-stdin%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
nohup runs the program with standard input redirected from /dev/null (assuming that you didn't redirect the nohup command itself). So no, you can't send input to this program.
If you want to send input to the program, redirect the input when you start it:
nohup program <input-file.txt & # input from a file
nohup data-producer | nohup program & # input from another program
mkfifo program.pipe; nohup program <program.pipe & # input from a named pipe, feed it what you want later
(Actually, it may be possible to reconnect the program's standard input to another source, by using ptrace, i.e. a debugger or other hack. This could crash the program if it keeps track where its input is from. See How can I pause up a running process over ssh, disown it, associate it to a new screen shell and unpause it?; there are other questions on the SE network on this topic.)
Won't data-producer get killed?
– wliao
Dec 5 at 18:00
1
@wliao Indeed. I've addednohupin front of it as well, thanks.
– Gilles
Dec 5 at 19:55
add a comment |
nohup runs the program with standard input redirected from /dev/null (assuming that you didn't redirect the nohup command itself). So no, you can't send input to this program.
If you want to send input to the program, redirect the input when you start it:
nohup program <input-file.txt & # input from a file
nohup data-producer | nohup program & # input from another program
mkfifo program.pipe; nohup program <program.pipe & # input from a named pipe, feed it what you want later
(Actually, it may be possible to reconnect the program's standard input to another source, by using ptrace, i.e. a debugger or other hack. This could crash the program if it keeps track where its input is from. See How can I pause up a running process over ssh, disown it, associate it to a new screen shell and unpause it?; there are other questions on the SE network on this topic.)
Won't data-producer get killed?
– wliao
Dec 5 at 18:00
1
@wliao Indeed. I've addednohupin front of it as well, thanks.
– Gilles
Dec 5 at 19:55
add a comment |
nohup runs the program with standard input redirected from /dev/null (assuming that you didn't redirect the nohup command itself). So no, you can't send input to this program.
If you want to send input to the program, redirect the input when you start it:
nohup program <input-file.txt & # input from a file
nohup data-producer | nohup program & # input from another program
mkfifo program.pipe; nohup program <program.pipe & # input from a named pipe, feed it what you want later
(Actually, it may be possible to reconnect the program's standard input to another source, by using ptrace, i.e. a debugger or other hack. This could crash the program if it keeps track where its input is from. See How can I pause up a running process over ssh, disown it, associate it to a new screen shell and unpause it?; there are other questions on the SE network on this topic.)
nohup runs the program with standard input redirected from /dev/null (assuming that you didn't redirect the nohup command itself). So no, you can't send input to this program.
If you want to send input to the program, redirect the input when you start it:
nohup program <input-file.txt & # input from a file
nohup data-producer | nohup program & # input from another program
mkfifo program.pipe; nohup program <program.pipe & # input from a named pipe, feed it what you want later
(Actually, it may be possible to reconnect the program's standard input to another source, by using ptrace, i.e. a debugger or other hack. This could crash the program if it keeps track where its input is from. See How can I pause up a running process over ssh, disown it, associate it to a new screen shell and unpause it?; there are other questions on the SE network on this topic.)
edited Dec 5 at 19:55
answered Dec 21 '10 at 23:28
Gilles
52.1k14113161
52.1k14113161
Won't data-producer get killed?
– wliao
Dec 5 at 18:00
1
@wliao Indeed. I've addednohupin front of it as well, thanks.
– Gilles
Dec 5 at 19:55
add a comment |
Won't data-producer get killed?
– wliao
Dec 5 at 18:00
1
@wliao Indeed. I've addednohupin front of it as well, thanks.
– Gilles
Dec 5 at 19:55
Won't data-producer get killed?
– wliao
Dec 5 at 18:00
Won't data-producer get killed?
– wliao
Dec 5 at 18:00
1
1
@wliao Indeed. I've added
nohup in front of it as well, thanks.– Gilles
Dec 5 at 19:55
@wliao Indeed. I've added
nohup in front of it as well, thanks.– Gilles
Dec 5 at 19:55
add a comment |
Thanks for contributing an answer to Super User!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2fsuperuser.com%2fquestions%2f224599%2fpipe-send-command-to-process-running-on-nohup-that-accepts-input-from-stdin%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
Linux (which)? Unix (which)? OS X? AmigaOS? It probably wouldn't hurt to say which shell. Bash? Bourne? Korn? C? Z? Fish?
– Dennis Williamson
Dec 21 '10 at 18:45
Sorry about that. Updated the question.
– vivin
Dec 21 '10 at 18:54