1

I am trying to edit a file using CGI C outside of cgi-bin (~/workspace/files/html) and I tried opening the using this code (edited workspacename and user):

pfile = fopen("https://workspacename-user.c9users.io/files/html/output.html", "w");

I get an internal server error and when I checked the error logs it showed:

[Wed Oct 05 18:40:12.350766 2016] [cgi:error] [pid 28008] [client 10.240.0.213:54468] End of script output before headers: test.cgi, referer: https://workspacename-user.c9users.io/files/html/main.html

I tried changing the location of the file that I am trying to open to the cgi-bin directly:

pfile = fopen("output.html", "w");

and it seemed to work. Is there a way to solve this?

2
  • 1
    You can't fopen() a URL in C (maybe you're used to PHP?). You need to give it a normal file system path. Commented Oct 5, 2016 at 19:19
  • 1
    "fopen accepts paths that are valid on the file system at the point of execution". Please see fopen Commented Oct 5, 2016 at 19:19

1 Answer 1

1

As it turns out, fopen cannot accept URLs. I tried editing the code to:

pfile = fopen("../../../home/ubuntu/workspace/files/html/output.html", "w");

and it worked.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.