LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   using wget to download a cgi file (https://www.linuxquestions.org/questions/linux-newbie-8/using-wget-to-download-a-cgi-file-631179/)

i.you 03-28-2008 01:00 AM

using wget to download a cgi file
 
Hi

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

Quote:

#!/bin/sh

sem=`cat /var/lock/semaphore`
sem=$(($sem+1))
echo -n $sem > /var/lock/semaphore

/bin/pidof rsyncmon > /dev/null
if [ $? -eq 0 ]; then
echo "Already running: rsyncmon"
return 0
fi
/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 :

Quote:

~# 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):
Code:

    echo "Content-type: text/html"
    echo
    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.