Solved

Loading an existing html file into a browser

Posted on 1998-07-01
7
147 Views
Last Modified: 2013-12-25
How can I load an existing HTML file into a browser from within a C cgi script? I 'm currently creating the HTML file on the fly but I want to create it only once and put it in a directory and then force the browser to reference it..
0
Comment
Question by:barlav
7 Comments
 
LVL 7

Expert Comment

by:faster
ID: 1830390
print "Content-type: text/html\r\n\r\n";

read html file and write the whole file to stdout


0
 
LVL 84

Expert Comment

by:ozo
ID: 1830391
Or, to force the browser to reference it

print "Location: http://some.machine/some.directory/some.doc\r\n\r\n";
0
 

Author Comment

by:barlav
ID: 1830392
I don't want to write a file out to stdout when it's already in existence. I want to force the browser to reference it. ozo's comment is close to the answer that I'm looking for but it doesn't work. I tried your answer ozo but it just creates a webpage that displays literally  "Location: http://some.machine/some.directory/some.doc\r\n\r\n" and not the html document that resides there.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:barlav
ID: 1830393
ozo,
  Your answer worked when I didn't set the MIME type ahead of time. Since you headed me in the right direction I'll be happy to award you the points if you submit your comment as an answer.
0
 

Expert Comment

by:chuckie_worm
ID: 1830394
That is one way of doing this, alternatively you could try the following.

  print "Content-type: text/html\n\n";              # HTTP header
  print "<SCRIPT LANGUAGE=\"JavaScript\">\n";
  print "window.location.replace = '**URL**'\n";
  print "</SCRIPT>\n";

where **URL** is the URL of the page that you want to display.

Chuckie
0
 

Author Comment

by:barlav
ID: 1830395
It seems that the way I'm doing it now is much easier. Thanks for your answer chuckie_worm but I think it's only fair that I give the points to ozo since he put me in the right direction.
0
 
LVL 84

Accepted Solution

by:
ozo earned 100 total points
ID: 1830396
Location: http://some.machine/some.directory/some.doc

  or
Refresh: 0; URL=http://some.machine/some.directory/some.doc
Content-type: text/html

  or
Content-type: text/html

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><meta http-equiv="refresh" content="0; url=http://some.machine/some.directory/some.doc">
</HEAD><BODY></BODY></HTML>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Powershell Find Folders 7 52
Powershell / new-object PSObject rows 2 210
How can I do this in Pyhton? 12 109
issue with beginner powershell script. 5 54
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now