-   Linux - Newbie (
-   -   using wget to download a cgi file ( 03-28-2008 01:00 AM

using wget to download a cgi file

I wrote a cgi file, HTTPD_ROOT/cgi-bin/lock.cgi, in target PC
in order to run some command on the target PC :



sem=`cat /var/lock/semaphore`
echo -n $sem > /var/lock/semaphore

/bin/pidof rsyncmon > /dev/null
if [ $? -eq 0 ]; then
echo "Already running: rsyncmon"
return 0
/usr/local/bin/rsyncmon &

return 0
and I ran wget on my PC :

then I could get the output - /var/lock/semaphore - on target PC
but it failed to download the cgi file, lock.cgi :


~# wget http://x.x.x.x/cgi-bin/lock.cgi
--14:31:11-- http://x.x.x.x/cgi-bin/lock.cgi
=> `lock.cgi'
Connecting to x.x.x.x:80... connected.
HTTP request sent, awaiting response...
NO response infinitely...

Any advice to download successfully?
Thanks in advance.

theNbomr 03-29-2008 10:37 AM

As part of the server, your CGI must send a proper HTTP response header. A useful HTML reply of some sort would be good as well.
Example (untested):

    echo "Content-type: text/html"
    echo "<HTML>"
    echo "<HEAD>"
    echo "<TITLE>LOCK CGI</TITLE>"
    echo "</HEAD>"
    echo "<BODY>"
    echo "Something useful here...."
    echo "</BODY></HTML>"

--- rod.

All times are GMT -5. The time now is 02:27 AM.