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:21

>>8
No, but I figured maybe you wanted to verify that I wasn't lying about file permissions or something.

It looks like I can stat the file.
struct stat hello;
if (stat("/home/donleyj/server/.wc", hello) < 0)
{
        error("could not stat");
}

Didn't return an error.

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