pt@beta.lanl.gov (Paul A. Thiessen) (06/24/89)
Okay all you UNIX hackers, answer me this. :-) Say I have a shell command program called 'put': for i do cat $i done I know, it's useless. But if I say 'put * >junk', I get the error message: 'cat: input junk is output' So is there any way that I can detect **before the cat statement** that a given file is the same one that is receiving redirected output? I'd like to have something like: for i do if (($i is not receiving stdout)) then cat $i fi done Thanks for any help! Please respond via e-mail as I don't usually read this newsgroup. - Paul -- ------------------------------------------------------------ PAUL THIESSEN (Summer only: pt@lanl.gov) pthiessen@hmcvax.bitnet ...uunet!jarthur!pthiesse ------------------------------------------------------------
bbausch@hpbbse.HP.COM (Bernd Bausch) (06/27/89)
Try the fstat system call. It returns information about a file, given a file descriptor. If you want to see whether two files are identical, check their device and inode number. I don't know how this works under NFS, though. Bernd.