Visit Our UNIX and Linux User Community


nohup - help!


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers nohup - help!
# 1  
Old 10-10-2007
nohup - help!

I find that if I use nohup (in bourne shell script) then all the interactive parts in my code are gone hidden... e.g., the places asking input from the user (such as ckyorn) will not be displayed. This is no good.

Is there a way to use nohup (or similar utility) and meanwhile, to keep the interactions with the user wherever required.

I know this is not how the nohup is usually used - we'd expect the program to do something in the background for a long time without interactions- but I want to make my installation program a bit more robust.

Thanks in advance for your help!
# 2  
Old 10-10-2007
Perhaps you don't understand the point of nohup.

The purpose is to allow a process to be detached from a controlling terminal and allow the process to continue running and not be killed by the SIGHUP generated when the login session closes.

stdin is normally replaced by /dev/null.

It is deliberately not designed for an interactive environment, and does it's best to detach itself from an interactive environment.

When code calls "istty(0)" it will find that user input is not from an interactive terminal, if you have not redirected stdin, it will read exactly zero bytes from stdin.
# 3  
Old 10-10-2007
Quote:
Originally Posted by bluemoon1
Is there a way to use nohup (or similar utility) and meanwhile, to keep the interactions with the user wherever required.
What are you trying to achieve? Why do you need it to run in the background if it's needs to ask for user input?
# 4  
Old 10-10-2007
Thanks you so much for your response.
so yes, you are absolutely right about everything you said!
And I wasn't clear about what I wanted to achieve.

The interactive part actually is in the begining of the program; after all answers are collected the installer is running silently - for that part I want it to be able to continue even if the terminal is killed.

I think it can be achieved by spliting the code into two scripts & apply the nohup on the second part.

Are you saying the answer will automatically be 0/null wherever the code reads input from stdin while using nohup?
Thanks again!
# 5  
Old 10-11-2007
Quote:
Originally Posted by bluemoon1
I think it can be achieved by spliting the code into two scripts & apply the nohup on the second part.
Absolutely!

Quote:
Are you saying the answer will automatically be 0/null wherever the code reads input from stdin while using nohup?
It shouldn't get *anything* unless you have redirected stdin.
# 6  
Old 10-11-2007
Code:
When code calls "istty(0)" it will find that user input is not from an interactive terminal, if you have not redirected stdin, it will read exactly zero bytes from stdin.

Does that mean if stdin is redirected to read from a file rather than its default input stream - interactive terminal, would stdin be still able to fetch bytes from the file ?

( assuming the binary is invoked along with ' nohup ' )
# 7  
Old 10-11-2007
Quote:
Originally Posted by matrixmadhan
Does that mean if stdin is redirected to read from a file....
Should do.

If that fails you can always do the stdin redirection in a wrapper script.
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #501
Difficulty: Easy
If a piece of code adds two numbers together and stores the result, there should be a comment that explains the process in the source code.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with nohup

I have a script test1.ksh (Korn shell) and within that I am calling another script test2.ksh test2.ksh runs for a pretty long time and hence wanted to execute as nohup from within test1.ksh nohup ./test2.ksh Question 1) dont think the above is working , although executing the nohup... (1 Reply)
Discussion started by: alldbest
1 Replies

2. Shell Programming and Scripting

Saving nohup output to a file other than nohup.out

Shell : bash OS : Oracle Linux 6.4 I want to save the ouput of a nohup command to file other than nohup.out . Below are my 3 attempts. For both Attempt1 and Attempt2 , the redirection logs the output correctly to the output file. But I get the error "ignoring input and redirecting stderr to... (7 Replies)
Discussion started by: kraljic
7 Replies

3. UNIX for Dummies Questions & Answers

Nohup

Hi Every one , i wrote a script for nohpu ,which checks the service by using the port number and starts if it doesnt hear the port. It works good untill i colse the session. how to make it work even after closing the session .And aslo how to deamoize this script #!/bin/bash netstat -ptlen |... (2 Replies)
Discussion started by: vikatakavi
2 Replies

4. UNIX for Dummies Questions & Answers

nohup

Hi, We are trying to run a shell script using nohup command. But this scripts asks for user input (username and password). Once we enter credentials it should continue run in background. Can someone please suggest how can we implement this? we can't modify .sh file since they are provided by... (5 Replies)
Discussion started by: blak
5 Replies

5. UNIX for Dummies Questions & Answers

When we need nohup

Hi, I've read the man page on nohup. But I still can't see what's the differences if we just send a process to background versus sending a nohup process to background. eg: myprocess & vs nohup myprocess & Without nohup, myprocess would still run uninterruptible at background... (2 Replies)
Discussion started by: ehchn1
2 Replies

6. Shell Programming and Scripting

Problem with nohup

Hello I am running this script inst.sh #!/bin/ksh sqlplus -s username/password @temp.sql ----Here is my temp.sql set serveroutput on select instance_name from V$instance; exit When i run the script inst.sh on the command prompt...it runs fine...but when i run it using... (5 Replies)
Discussion started by: njafri
5 Replies

7. AIX

nohup.out

I have a program which writes to nohup.out ... over the time this nohup.out becomes a large file and i cannot read the contents of this file using a vi editor.... whe i do a vi nohup.out it gives an error insufficient memory.... do i need to clean this nohup.out periodically ( or compress it... (5 Replies)
Discussion started by: ramky79
5 Replies

8. Solaris

NOHUP not working

Hello All, Here is a problem of NOHUP. I am trying to run a process which needs to be up and running even if the session is closed. I tried running it with "nohup", but starngely it is not working, when i exit from the session the process is also getting killed? plz help me in finding out... (4 Replies)
Discussion started by: shivamasam
4 Replies

9. UNIX for Advanced & Expert Users

Help on nohup

Hi I submitted a long running executable without using nohup. Now, is there any way I can assure to keep that process ON even if my session gets killed? Thanks Bobby (3 Replies)
Discussion started by: bobbyjohnz
3 Replies

10. UNIX for Dummies Questions & Answers

Nohup

Hi, Using nohup it sends output automatically to $HOME/nohup.out - how do I direct this output to another named file instead, so I can run several scripts in the background at once, directing their outputs into individual log files? Cheers (3 Replies)
Discussion started by: miwinter
3 Replies

Featured Tech Videos