[19. April 2013] A-400 Advanced Network Setup now available | [11 Jan. 2013] Customize your A-400 Home Screen

Firmware: A-400 [13 May 2013] | C-300 [30 Nov. 2012] | A-300 [30 Nov. 2012] | C-200 [21 Jan. 2013] | A-200/A-210 [10 Aug. 2012]

Just got your NMT | WIKI has the answers | Search the forum | Forum Rules/Policy | Firmware & Official NMT News | Popcornhour manuals



User(s) browsing this thread: 1 Guest(s)
Thread Closed 
Passing parameters to a CGI program
03-20-2009, 11:30 AM
Post: #1
Passing parameters to a CGI program
I am trying to write a cgi program which takes some parameters. I have the following test cgi file:

Code:
#!/bin/sh

start_html()
{
        echo "Content-Type: text/html"
        echo ""
        cat <<EOF
<html>
<head>
<title>
Title
</title>
</head>
<body>
EOF
}


# Send the closing HTML
end_html()
{
  cat <<EOF
</body>
</html>
EOF
}

start_html

cat <<EOF
parm1=$1
parm2=$2
input1=$INPUTPARM1
input2=$INPUTPARM2
EOF

end_html

exit 0

If I call it like this, $1 comes through as expected (I use the Play button to activate the link):
Code:
<a href="http://localhost.drives:8883/HARD_DISK/test.cgi?test" TVID="PLAY"/>

parm1=test
parm2=
input1=
input2=

However, if I try to set up a variable like this, it does not work as expected:
Code:
<a href="http://localhost.drives:8883/HARD_DISK/test.cgi?INPUTPARM1=test" TVID="PLAY"/>

parm1=INPUTPARM1=test
parm2=
input1=
input2=

Multiple input variables are also not working as expected:
Code:
<a href="http://localhost.drives:8883/HARD_DISK/test.cgi?INPUTPARM1=test&INPUTPARM2=test" TVID="PLAY"/>

parm1=INPUTPARM1=test1%26INPUTPARM2=test
parm2=
input1=
input2=

Am I doing something wrong? Is what I am trying to do even possible?
Find all posts by this user
03-20-2009, 11:36 AM
Post: #2
RE: Passing parameters to a CGI program
You are doing nothing wrong, just all the HTTP GET parameters are stored in $1.
You need to manually split them to correct variables.

More information is available here:
http://bash-hackers.org/wiki/doku.php/mi...ashfaq/092

Easy way of installing software on your NMT using just your mouse: NMT Community Software Installer
Visit this user's website Find all posts by this user
03-20-2009, 11:43 AM
Post: #3
RE: Passing parameters to a CGI program
Ah right, of course.

Thanks for the quick reply. I saw examples somewhere of being able to pass in key/value pairs to a CGI, but I guess those programs were manually splitting the parms as you suggest.
Find all posts by this user
Thread Closed 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Is there a program for Tunning my hdtv? Psychoholic 7 3,162 02-11-2010 10:22 AM
Last Post: chris57
  Run CGI file from Webservice ceilath 1 1,644 02-10-2010 06:54 PM
Last Post: ceayuso
  Howto customize mono parameters? lcars 5 2,127 01-02-2010 08:29 PM
Last Post: garp99
  uclibc error when running simple compiled program b.lefoll 5 4,710 10-11-2009 10:27 PM
Last Post: artn3r
  Problems of running cgi files.... hispanico 8 2,445 10-03-2009 09:48 PM
Last Post: hispanico
  how to test if a file exists in xslt program jluc2808 11 8,096 10-02-2009 11:26 PM
Last Post: jluc2808
  preview the html part from a cgi file ? meowmoo 1 1,126 06-10-2009 12:53 AM
Last Post: mhut
  Parameters Yahoo Weather Espartaco 1 973 05-04-2009 04:32 AM
Last Post: HEBEGB
  Spurious output when using php5-cgi bellissimo 1 786 04-26-2009 07:26 PM
Last Post: bellissimo
  Running a program/process automatically on startup? Legion455 3 1,951 04-10-2009 06:12 PM
Last Post: cheesebread

Forum Jump: