The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
nohup.out ramky79 AIX 5 10-23-2007 03:28 AM
Help on nohup bobbyjohnz UNIX for Advanced & Expert Users 3 10-18-2006 08:56 AM
nohup ( no log message) mike1022 Shell Programming and Scripting 1 09-16-2006 05:55 PM
Nohup miwinter UNIX for Dummies Questions & Answers 3 07-21-2006 02:20 AM
nohup usage.. charan81 UNIX for Dummies Questions & Answers 2 05-21-2006 11:41 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-10-2007
Registered User
 

Join Date: Sep 2007
Posts: 53
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!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-10-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
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.
Reply With Quote
  #3 (permalink)  
Old 10-10-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by bluemoon1 View Post
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?
Reply With Quote
  #4 (permalink)  
Old 10-10-2007
Registered User
 

Join Date: Sep 2007
Posts: 53
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!
Reply With Quote
  #5 (permalink)  
Old 10-10-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by bluemoon1 View Post
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.
Reply With Quote
  #6 (permalink)  
Old 10-10-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,573
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 ' )
Reply With Quote
  #7 (permalink)  
Old 10-10-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by matrixmadhan View Post
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0