The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

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
compare null with non-null nitin Shell Programming and Scripting 8 11-04-2006 03:58 PM
Help on nohup bobbyjohnz UNIX for Advanced & Expert Users 3 10-18-2006 08:56 AM
Nohup miwinter UNIX for Dummies Questions & Answers 3 07-21-2006 02:20 AM
Redirection or piping error message mariner Shell Programming and Scripting 2 05-10-2005 12:04 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-28-2006
Registered User
 

Join Date: Feb 2006
Posts: 4
error piping nohup to /dev/null

Hi,

I have a script as follows:

#!/bin/sh

nohup ./my_program >& /dev/null &

However, i get a "Generated or received a file descriptor number that is not valid" whenever I run it.

running the command up in prompt is ok though.

if i change the first line to #!/bin/csh
i get a then: then/endif not found.

Pardon my ignorance but I really can't solve this problem.

Can anyone kindly offer some advice?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-01-2006
Registered User
 

Join Date: Feb 2006
Posts: 61
try getting rid of the first '&'.
Reply With Quote
  #3 (permalink)  
Old 03-01-2006
Registered User
 

Join Date: Feb 2006
Posts: 4
ScatterBrain is right - but you may want to send any errors to std err for inital debugging.

try:

Code:
#!/bin/sh

nohup ./my_program > error.log 2>&1
Reply With Quote
  #4 (permalink)  
Old 03-01-2006
Registered User
 

Join Date: Feb 2006
Posts: 61
...or how about...

nohup ./my_program >/dev/null 2>error.log &

that is, if you don't care about standard output... but just wanna see stderr messages.

if you intend to do this a lot... or permanently with this script, you may want to consider adding within the script something like this:

exec 1>/dev/null
exec 2>error.log (or exec 2>&1 if you want no output at all)
Reply With Quote
  #5 (permalink)  
Old 03-01-2006
Registered User
 

Join Date: Feb 2006
Posts: 4
Thanks!

Thanks! U guys are great! I removed the first & and it really works.
I'm still baffled why including the first & will work in the command prompt but
not within the script though.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:50 PM.


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

Content Relevant URLs by vBSEO 3.2.0