Pipe/send command to process running on nohup that accepts input from STDIN












3














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.










share|improve this question
























  • 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
















3














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.










share|improve this question
























  • 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














3












3








3


2





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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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










1 Answer
1






active

oldest

votes


















6














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.)






share|improve this answer























  • Won't data-producer get killed?
    – wliao
    Dec 5 at 18:00








  • 1




    @wliao Indeed. I've added nohup in front of it as well, thanks.
    – Gilles
    Dec 5 at 19:55











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
});


}
});














draft saved

draft discarded


















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









6














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.)






share|improve this answer























  • Won't data-producer get killed?
    – wliao
    Dec 5 at 18:00








  • 1




    @wliao Indeed. I've added nohup in front of it as well, thanks.
    – Gilles
    Dec 5 at 19:55
















6














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.)






share|improve this answer























  • Won't data-producer get killed?
    – wliao
    Dec 5 at 18:00








  • 1




    @wliao Indeed. I've added nohup in front of it as well, thanks.
    – Gilles
    Dec 5 at 19:55














6












6








6






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.)






share|improve this answer














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.)







share|improve this answer














share|improve this answer



share|improve this answer








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 added nohup in front of it as well, thanks.
    – Gilles
    Dec 5 at 19:55


















  • Won't data-producer get killed?
    – wliao
    Dec 5 at 18:00








  • 1




    @wliao Indeed. I've added nohup in 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Plaza Victoria

Brian Clough

Cáceres