- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This days i try to complete the CGI function in the uClinux BOA of my 1s10 board,but no results.
And wanna achieve the ledcontrol (http://www.niosforum.com/forum/index.php?act=st&f=18&t=2185) via the cgi function on boa. I have tried different ways. >1:index.html //add to home/httpd folder. follow what KEN's method, change "POST" to "GET":
<html>
<head>
<title>CGI script test</title>
</head>
<body>
<form method="get" action="http://202.112.147.82/cgi-bin/test.cgi">
<input type="submit" value="ok">
</form>
</body>
</html>
>2:creat test.cgi //add to home/httpd/cgi-bin folder. one way: ## cgi-bin/test.cgi#
# ! /bin/sh
echo "Content-type: text/html\n\n"
echo
echo "The cgi script is working\n"
another way://Compile to test.exe,then add test.exe to home/httpd/cgi-bin folder. #include <stdio.h>
void main(void)
{
printf("content-type: text/html\n");
printf("\n");
printf("the cgi script is working\n);
exit(0);
}
Unfortunately,error in IE browser: the page cannot be displayed,server inner error... Also i browsered the concerning topic, just like the TOPIC:"How to use boa?" by sunclever. No result to find,even i follow the same way, but no success. Any help would be greatly appreciated! Thank you very much! Best regards! Justin
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you were trying to use the shell script that I posted, there may be an error in it.
I inadvertently added some comments before the "#! /bin/sh" and I think that may affect whether or not Linux will run the script through the shell interpreter or treat it as a full blown executable. The correct script should be:#! /bin/sh
# # cgi-bin/test.cgi#
echo "Content-type: text/html\n\n"
echo
echo "The cgi script is working\n"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ken:
I have tried again,using the correct code below:#! /bin/sh
# # cgi-bin/test.cgi#
echo "Content-type: text/html\n\n"
echo
echo "The cgi script is working\n"
However, when i click the "ok" button in the index.html,no page to find, the ie address is: http://202.112.147.82/cgi-bin/test.cgi (http://202.112.147.82/cgi-bin/test.cgi)? I really don't know where the problem is, and why not use this below code #include <stdio.h>
void main(void)
{
printf("content-type: text/html\n");
printf("\n");
printf("the cgi script is working\n);
exit(0);
}
BOA in the distribution doesn't support this? Thank you again~! Best Regards! Justin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm using scripts because it reduces my debug time if I do everything on Nios II Linux. So, I've gone into the boa.conf file and I've moved my document root from /home/httpd to /var/www and I use "busybox vi" to make a new index.html and test.cgi each time I try these tests.
Things to watch out for: (1) Your CGI script must end with a .cgi suffix... i.e. test.cgi... or foo.cgi... or bar.cgi... (2) If you're compiling a C program to be your CGI script, then you should compile it to foo.cgi.exe... This will be renamed to foo.cgi and it will be given execute permissions when the filesystem is built. (3) Finally, the CGI script *must* have execute permissions... try executing your script from the commandline. If it doesn't *exactly* spit out:Content-type: text/htmlnn
The cgi script is workingn
Then there's something wrong with the script itself. I really have no idea why you're getting those server errors. I'm assuming that ip address you've listed in the IP address for your Nios II Linux Board. I tried the same thing except with my own IP address (10.1.1.125) and it found the test.cgi file without a problem. Can you show me what is exactly in your document root directory (recursively)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm also having trouble getting CGI to work.
I am using the Altera 1C20 board. I've created a kernel and file system following the quickstart guide. I've added my html files to the httpd directory. <html> <head> <title>CGI script test</title> </head> <body> <form method="get" action="http://202.112.147.82/cgi-bin/test.cgi"> <input type="submit" value="ok"> </form> </body> </html> Inserting my own IP address... Added a subdirectory /cgi-bin/ Added the "ScriptAlias /home/httpd/cgi-bin/ /cgi-bin/" to the boa.conf file. Then I created the script: # ! /bin/sh # # cgi-bin/test.cgi# echo "Content-type: text/html\n\n" echo echo "The cgi script is working\n" I saved the script as test.cgi.exe in my filesystem /home/httpd/cgi-bin Which when uploaded changed to test.cgi. I bring up the server, and get the page that has the "OK" button which should kick off the script. I press the button and get a "500 Server Error" back. Any clue as to what I'm forgetting? Thanks, Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm wondering if the script might have been saved with dos linefeeds... That would prevent the script from starting properly which would in turn could cause a 500 error (if I remember my error codes correctly).
Can you confirm that?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I created the script using the NIOS II IDE, so I assume that it doesn't have DOS LF's inserted. I saved the file as "test.cgi.exe"
Is there a quick way to verify that there are no special characters thrown in? Thanks, Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> Is there a quick way to verify that there are no special characters thrown in?
You can just run dos2unix ... it'll make sure everything is converted: $ dos2unix test.cgi.exe Regards, --Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
dumping the DOS LF's didn't help with the error. Any other thoughts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you able to run the script using from the commandline?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
nope. It can't recognize echo. Any idea why the script wouldn't work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi schaney,
> nope. It can't recognize echo. Any idea why the script wouldn't work? This sounds weird ... I ran the following script without any problems:#!/bin/sh
echo "Content-type:text/html\n\n"
echo "The cgi script is working\n"
Here are a few things to check: 1. Try the following command: $ echo $PATH If this doesn't work ... you're probably missing 'echo'. 2. Check your PATH environment If the PATH env var doesn't include the directory where echo actually is, you'll either need to add the full path to your script, or setup PATH in your /etc/rc file. Or from the command line: $ export PATH=$PATH:<path to echo> Then try running the script again. Regards, --Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That would be the problem. I didn't have the sh utilities built into the filesystem.
Thanks, Scott
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page