Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

CGI problem

Altera_Forum
Honored Contributor II
946 Views

Hello: 

 

I am testing a CGI program using C language and Shell under the Nios2 Linux system. 

What I want is to implement the "Redirection" function to redirect user's browser to a website: 

for exmaple "www.google.com". 

 

My approach is to print the "Location: URL" header to user's browser. 

What I did is like this, I wrote a C program that is doing simple I/O access,and contains the last line: 

printf("Location: http://www.google.com\n\n"); (http://www.google.com\n\n&quot%3b%29;) 

 

I also wrote a shell scirpt which was: 

# !/bin/sh 

echo "Location: http://www.google.com" (http://www.google.com") 

echo "" 

 

Finally,I put them into the proper place and tried to link them using IE. 

Both execution turned out successful(I/O result was correct),but they did't bring me to google! 

 

After the execution,both of them only took me to the previous folder. 

(i.e. from http://192.168.1.1/cgi-bin/test.cgi (http://192.168.1.1/cgi-bin/test.cgi) to http://192.168.1.1/cgi-bin/ (http://192.168.1.1/cgi-bin/) ) 

 

Can anyone please tell me what's the problem!? 

Thank you so much. 

 

Best Regards.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
264 Views

I presume that you're using boa?

0 Kudos
Altera_Forum
Honored Contributor II
264 Views

Hello clansdown: 

Yes,I am using boa.
0 Kudos
Altera_Forum
Honored Contributor II
264 Views

Two other questions: 

 

(1) What happens if you go to it manually, e.g. 

 

telnet host 80 GET /cgi-bin/test.cgi HTTP/1.1 Host: hostname  

 

(2) What happens if you use some other browser, such as Firefox?
0 Kudos
Reply