in reply to chmod for cgi

Well, chmod works in CGI scripts the same as anyplace else. There are complications in some flavors of *nix (e.g., ACLs in HP-UX), but basically, the process calling chmod needs to be the same owner as the target directory. The issue is not how chmod works; what usually trips up attempts like this is one of two things:

  1. The directory the CGI is executing in is not the same as the one where you're executing it from command line (thus, '.' is different).
  2. The user under which the CGI is executing is not the same as the one executing it from the command line.

Figure out these two and you will probably fix the problem. If not, there may be deeper issues. In that case, post another question.