Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!sdd.hp.com!think.com!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.programmer Subject: Re: system() question Message-ID: <1991Feb22.042314.453@athena.mit.edu> Date: 22 Feb 91 04:23:14 GMT References: <9321@hub.ucsb.edu> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 29 In article <9321@hub.ucsb.edu>, 6600bori@ucsbuxa.ucsb.edu (Boris Burtin) writes: |> Can anyone tell me why I get a core dump |> when I try to do : |> |> system("last [username] > ~/filename"); I have no idea why you get a coredump, and there's no way really for us to tell. Have you attempted to analyze the coredump with a debugger to see what it's from? Is it your process coredumping, or is it the shell that's being started? I don't get a coredump on my machine. What type of machine are you using, running what version of Unix? In any case, I suspect that at least part of the problem is that the bourne shell, which is what system uses, doesn't understand "~". Change the "~" to "$HOME". Observe: 1 -> extern int system(char *); 2 -> system("last jik > ~/lastjik"); Linking from '/lib/libc.a' ... Linking completed. sh: ~/lastjik: cannot create (int) 256 3 -> system("last jik > $HOME/lastjik"); (int) 0 -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710 Brought to you by Super Global Mega Corp .com