How to truncate existing file

How to truncate existing file

Post by Michael Uma » Thu, 27 Apr 2000 04:00:00


Could a kind soul out there please help out an programmer in need...

How does one go about truncating an existing file? If there is a file
which is 2Megs in size and I would like to truncate it at the 1Meg
point, how would you do that using UNIX system calls? I have a suspicion
it includes using the 'fcntl' function, but haven't been able to deduce
how to accomplish this...

Any help will be appreciated...


// PROGRAMMER  : Michael A. Uman
// PROJECT     : Email Signature
// TITLE       : Senior Software Engineer



How to truncate existing file

Post by Marku » Thu, 27 Apr 2000 04:00:00


>How does one go about truncating an existing file?

truncate(2), ftruncate(2)


1. Apache 1.3.9: File does not exist: path-to-existing-file

I'm having a problem with Apache 1.3.9 which I have been unable to figure out.

When most users go to "", it works. Nothing
appears within the error log, and The following two lines appear within the
transfer log: - - [22/Dec/1999:11:07:30 -0500] "GET /Ottawa/pageant
      HTTP/1.0" 301 238 - - [22/Dec/1999:11:07:30 -0500] "GET /Ottawa/pageant/
      HTTP/1.0" 200 2256

When one particular user (that I'm aware of so far) tries it, however, it does
not work. Whenever he tries, the transfer log contains: - - [03/Jan/2000:18:48:36 -0500] "GET /Ottawa/pageant"
      HTTP/1.1" 404 276
and the error log contains:
   [Mon Jan  3 18:48:36 2000] [error] [client]
      File does not exist: /RPChurch/home/html/Ottawa/pageant"

The path shown in the error log, i.e. "/RPChurch/home/html/Ottawa/pageant",
Does exist. The permissions on all of its directories are 755, and the
permission on the index.html file is 644.

I asked the user to try "" (trailing slash
added), and "" as well. Both of
these failed in the same manner.

I cannot find anything within the httpd.conf file which is client address
specific, and I've insured that every single BrowserMatch directive listed
witin the Apache server documentation is present. The user's agent gets logged

    Mozilla/4.0 (compatible; MSIE 4.0; Windows 95)

Do any of you have any idea regarding why this particular user is having this
particular problem? What else should I check?


Dave Mielke           | 856 Grenon Avenue | I believe that the Bible is the
Phone: 1-613-726-0014 | Ottawa, Ontario   | Word of God. Please contact me

2. Editing xinitrc & menu items

3. Tie::File truncates large files when doing a shift

4. apache and mod_ssl compiling problem

5. Truncating file from file descriptor

6. Sort behavior?

7. Truncating the file without closing the file.

8. rzsz9402 + minicom problems

9. truncated a file with "> file" but size comes back with "ls"

10. "File exists writing symlinking article file -- throttling"

11. picking up newly installed files from existing files

12. 'cat file' but only if 'file' exist

13. Removing files while file descriptor still exists.