monkey webserver and bash issues

This forum is for Marvell Kirkwood devices such as the GoFlex Home/Net, PogoPlug v1/v2, SheevaPlug, and ZyXEL devices.

monkey webserver and bash issues

Postby gschoppe » Wed May 01, 2013 5:08 am

I am new to monkey webserver, and to cgi, and am having a lot of trouble making things work.

My goal is to have a cgi script that generates a single line of javascript, containing my device's public IP.

The code I have looks like this:
$this->bbcode_second_pass_code('', '
#!/usr/bin/bash
echo Content-type: text/javascript
echo ""
localip=$(curl ifconfig.me)
echo "var ip='$localip';"
')

it seems to work when I run it with bash directly, but in monkey, it gets downloaded as a file, rather than executed.

I installed monkey with pacman -Sy monkey, then uncommented the cgi plugin in /etc/monkey/plugins.load, then created a folder in /srv/http/ called cgi-bin, then saved that script as ip.sh, and ran monkey in daemon mode.

help?
gschoppe
 
Posts: 28
Joined: Thu Feb 21, 2013 11:58 pm

Re: monkey webserver and bash issues

Postby moonman » Wed May 01, 2013 5:45 am

I have actually never used monkey myself, but it does seem to be the lightest http server. Try changing the extension of your script to .cgi, maybe it will pick it up then. If it doesn't work, then try lighttpd. It would probaly be the second lightest http server. It is well documented and there are lots of examples so it should be easier to setup.
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am

Re: monkey webserver and bash issues

Postby rhester72 » Wed May 01, 2013 1:22 pm

It's like any other web server - if you don't explicitly tell it that it can run CGI, it won't.

I presume you have something like this in your monkey config file? (I don't use monkey, just Google-fu)

$this->bbcode_second_pass_code('', '
Server_ScriptAlias /cgi-bin/ /root/webserver/cgi-bin
')

Rodney
rhester72
 
Posts: 35
Joined: Tue Apr 30, 2013 4:24 pm


Return to Marvell Kirkwood

Who is online

Users browsing this forum: No registered users and 18 guests