LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   writing a cgi to redirect to another webpage (https://www.linuxquestions.org/questions/programming-9/writing-a-cgi-to-redirect-to-another-webpage-6703/)

JustinHoMi 09-19-2001 12:42 PM

writing a cgi to redirect to another webpage
 
Hey folks. I don't know an ounce of perl, and my c is pretty weak, but I need to write a couple of cgis. So, my idea was that I could have a simple cgi that would call a shell script (something I can do! :)) and then redirect to a webpage, say, mypage.html. I understand that I could use something like this (with perl) for the former:

@output = `/bin/sh /home/matt/scripts/script.sh`;

or

system("/bin/sh /home/matt/scripts/script.sh");


Now, script.sh is going to generate mypage.html, so I'd like the cgi to there. Is there a good and simple way to do this?

Any help would be greatly appreciated!

Thanks,
Justin

crabboy 09-28-2001 07:22 PM

Not that fully understand what you are asking, but here is cgi script writtin in sh that will do anything you want then redirect you somewhere else. This is untested.
Code:

#!/bin/sh

# do whatever

echo Content-type: text/html
echo

cat << EOF

<HTML>

<meta http-equiv="Refresh" content="1; url=http://www.cnn.com">

</HTML>


JustinHoMi 09-28-2001 08:08 PM

Oh, that works! I didn't realize you could use a shell script for a cgi. I had tried, but I guess I had mistyped something.

Thanks, even better than what I'd asked for! :)

Justin


All times are GMT -5. The time now is 01:28 PM.