CGI <href> question

A

araminska

I am playing with cgi-scripting in Perl, not for a web site, but to see if
it is a valid method (for me) to write programs that are accessable by any
operating system. I have programmed for years, but the only web stuff I
have ever done is very trivial static HTML pages. So far so good.

But I am stuck on how to setup an <href> to download a file from inside
the script. In a static html page, anything the browser doesn't
recognise as a valid script is automatically presented for download. But
in a script everything I try wants to be run as a script.

Anybody?
Araminska
 
J

Jukka K. Korpela

Scripsit araminska:
But I am stuck on how to setup an <href> to download a file from
inside the script.

You should start by defining what you mean by that.

There is no <href> element in HTML, to begin with.

No element or attribute "does" anything. They're data. Data doesn't "do"
things, except in Star Trek.

And markup doesn't reside "inside" a script, and HTML doesn't deal with
"files". Specifically, an href attribute takes a URL value, and whether
a URL gets actually mapped to a file depends on the _server_ (unless you
use file: URLs, which are strictly system-dependent and thus generally
useless on the Web).
In a static html page, anything the browser
doesn't recognise as a valid script is automatically presented for
download.

What on &Planet; are you talking about?
But in a script everything I try wants to be run as a script.

I don't see why that surprises you.

Maybe you should simply start by explaining in plain terms what you are
doing, and illustrate it with some URLs.
 
J

Jeff

araminska said:
I am playing with cgi-scripting in Perl, not for a web site, but to see if
it is a valid method (for me) to write programs that are accessable by any
operating system. I have programmed for years, but the only web stuff I
have ever done is very trivial static HTML pages. So far so good.

But I am stuck on how to setup an <href> to download a file from inside
the script. In a static html page, anything the browser doesn't
recognise as a valid script is automatically presented for download. But
in a script everything I try wants to be run as a script.

I'm a little confused about exactly what you are doing.

I think you have a script that prints a file. Before you print that
file you'll want to also print the content-type and possibly the content
disposition. You're actual content will start after the first blank line.

For example, here is a typical header for a CSV file that will open
an application:

Content-Disposition: inline; filename=some_file.csv
Content-Type: application/x-csv

Actual file starts here...

Jeff
 
A

araminska

Never mind. I got the answer over on the Perl board, which fortunately
has programmers rather than script kiddies who apparently like to post
rather than read.

Araminska
 
J

Jeff

araminska said:
Never mind. I got the answer over on the Perl board, which fortunately
has programmers rather than script kiddies who apparently like to post
rather than read.

And a screw you right back at you.

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top