Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bellcore!att!emory!gatech!udel!princeton!phoenix.Princeton.EDU!pfalstad From: pfalstad@phoenix.Princeton.EDU (Paul Falstad) Newsgroups: comp.unix.questions Subject: Re: Odd ouput redirection in background script Keywords: Odd, strange, wierd, csh, shell, background, script Message-ID: <5971@idunno.Princeton.EDU> Date: 5 Feb 91 16:08:08 GMT References: <1991Feb4.211315.13175@cec1.wustl.edu> Sender: news@idunno.Princeton.EDU Organization: The E. Henry Thripshaw Fan Club Lines: 28 flan@cics.Berkeley.EDU (Ian Flanigan) wrote: >#!/bin/csh >ls > /tmp/tt$$ > close(0); > close(1); > execvp(argv[0],&argv[1]); >Easy. Now I gave it a test with, "background test_scr" and it wrote the >directory listing to my screen. My question: Why? Not only did I close >stdout, but I also had it re-directed in the script. Is it a probelem >with the shell? Yes, this is a bug in csh. You should not call csh with stdin closed; you should at least assign it to /dev/null. If you don't, csh will get the file descriptors confused, so that stdout will become stdin, and stderr will become stdout. The output of ls in your case was being written to stderr. This is in the csh bug list, which I ftp'ed from I forget where. I know you mentioned that you got it working some other way, but you might want to check out question #12 in the FAQ for more info on how to get rsh to work the way you want it to. -- Paul Falstad, pfalstad@phoenix.princeton.edu PLink:HYPNOS GEnie:P.FALSTAD 10 PRINT "PRINCETON CS" | #include 20 GOTO 10 | I think sexual ecstasy's overrated.