1

I don't know much about web programming and I would really appreciate the help on this.

I have an HTML page that has an input field:

<input type="text" size=20 />

I want to run a CGI script that will return a value so that I can put it in the input field as a default when the page first loads.

So it would look like this I guess:

<input type="text" size=20 value=Run CGI script />

The script is a shell script that I named hostname.cgi and it contains the following:

#!/bin/sh

printf "Content-type: text/html\n\n"
printf $REMOTE_ADDR

When I try using

value=<!--include virtual="hostname.cgi" -->

I get an error on the HTML page that says an error occurred while running this directive (or something like that).

What am I doing wrong? Also, the script is in the same directory as the html file. Other CGI scripts on the page work just fine.

2
  • If it says an error occurred when running the SSI, look in your server error logs to find out what the error was. Commented Apr 13, 2012 at 18:54
  • Sounds like you need some AJAX Commented Apr 13, 2012 at 19:35

2 Answers 2

1

Not sure what you're trying to do here, I would really have to see the whole code. However, I suspect it's somethign to do with your format and the action defined:

<form action="/some_script_name" method="post">
<input type="text" name="ab" value="">
<input type="submit" value="Submit">
</form>

You also need to surround attributes with quotes:

<input type="text" size="20" value="Run CGI script" />
Sign up to request clarification or add additional context in comments.

Comments

1

To put some default value somewhere as generated by a CGI script, you need to make the entire page generated by a CGI script. This means that the address of the page would be a reference to such a script. The details depend on the programming language used for the CGI script.

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.