Thread: Problem with cgi script - can't rename files

  1. #1
    Registered User
    Join Date
    Nov 2001

    Talking Problem with cgi script - can't rename files

    I've come across a problem trying to create new files and rename files on a Linux server through a cgi script - written in C. I seem to only be able to open existing files, read existing files and write to existing files when a script is executed by opening it on a browser (accessing cgi through internet). I can't seem to create a new file, nor can I rename an existing file through a cgi script, but I can do this with a normal C program on the server. I'm not a brilliant C programmer by any stretch of the imagination but I am generally competent, but still learning. I gather is has something to do with the settings for cgi-bin directory and programs executed from it? Or is it a standard I/O thing? Or am I wrong in both my guesses?
    All I want to be able to do through my cgi script is create a new file on my server and rename it. Using fopen(filename, "w") - doesn't work, and how do you rename a file? Can anyone help me, your help will be much appreciated ! Been toiling over this for days !

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Renaming files is very hard to do. No, wait, that's wrong. It doesn't get much easier than this. rename()

    You're likely running into a permissions problem. Most CGI scripts, and thus, the directory, do not have write permission. Without it, you're not able to do what you want here. Generally your CGI directory is going to have read and execute permissions, not write.

    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Nov 2001

    Thanks a Million

    HI Quzah,
    you were right - it was a write permission problem. Many many thanks, much appreciated,

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Resource Script Problem
    By ltanusaputra in forum Windows Programming
    Replies: 2
    Last Post: 06-02-2007, 09:08 AM
  2. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  3. problem while opening files from multiple directories
    By V.G in forum Windows Programming
    Replies: 2
    Last Post: 11-08-2004, 03:29 PM
  4. I have a problem if FILEs
    By talal*c in forum C Programming
    Replies: 22
    Last Post: 01-07-2002, 05:56 AM
  5. problem reading files in C
    By angelfly in forum C Programming
    Replies: 9
    Last Post: 10-10-2001, 11:58 AM