Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

fopen says file does not exist

Name: Anonymous 2010-09-27 19:38

I'm trying to make a call to fopen in C, but it says the file doesn't exist. Except it does. The file gets created during execution and I have verified that it does, in fact, get created (and it does contain what I want it to). I chmodded the file and its parent directory to 755 but that didn't help anything. Here's the code.

// wc -l ~/server/.tmp | sed 's/ .*//g' > ~/server/.wc
// line count --> erase the filename --> store in file .wc
if ((system("wc -l ~/server/.tmp | sed 's/ .*//g' > ~/server/.wc")) < 0)
{
    error("tried to wc");
}
// send the wordcount and a null
if ((fileBuf = fopen("~/server/.wc", "r")) == NULL)
{
    error("tried to open .wc");
}

error just calls a function that does perror and then exits. When it tries to open the file, it prints "tried to open .wc:  No such file or directory".

Name: Anonymous 2010-09-27 20:10

>>6
I'll start with the easier one, then.
$ stat .wc
  File: `.wc'
  Size: 2               Blocks: 8          IO Block: 32768  regular file
Device: 12h/18d Inode: 119276480   Links: 1
Access: (0755/-rwxr-xr-x)  Uid: ( 4417/ (myname))   Gid: (  500/   users)
Access: 2010-09-27 19:14:02.785057213 -0400
Modify: 2010-09-27 19:47:27.622168948 -0400
Change: 2010-09-27 19:47:27.622168948 -0400

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List