You are not logged in.

#1 2008-02-03 19:38:34

pyther
Member
Registered: 2008-01-21
Posts: 1,395
Website

Run script from web interface... help?

Hello
I want to create a very simple interface with 2 variables, ENDHOUR and ENDMINUTES

After the user enter these two variables, I would like to run

/home/pyther/bin/audio-recorder.sh -h ENDHOUR -t ENDMINUTES

In addition I would also like to output

`ps aux | grep -v 'audio-recorder.sh' | grep -v 'grep' | grep 'rec -q -c 2'

below. How can I do this?

I'm thinking I would want to use python or something like this. My knowledge with web backends are very limited, so examples or guides would be great!

Thanks,
Pyther


Website - Blog - arch-home
Arch User since March 2005

Offline

#2 2008-02-03 21:47:44

nj
Member
Registered: 2007-04-06
Posts: 93

Re: Run script from web interface... help?

I really like web.py for small web apps like this. Below is some code which should get you started. You'll want to add in some error checking.

import web
import os

urls = (
  '/', 'hello'
)

class hello:
    def GET(self):
        print """
        <form method='post' action='.'>
        hour: <input type='text' name='endhour' /><br />
        minutes: <input type='text' name='endminutes' /><br />
        <input type='submit' value='submit' />
        </form>
        """
        print '<br /><br />'
        print '<br />'.join(os.popen("ps aux | grep -v 'audio-recorder.sh' | grep -v 'grep' | grep 'rec -q -c 2'").readlines())

    def POST(self):
        i = web.input()
        os.popen("/home/pyther/bin/audio-recorder.sh -h %s -t %s" % (i.endhour, i.endminutes))
        web.seeother('/')


if __name__ == "__main__": web.run(urls, globals())

Last edited by nj (2008-02-03 21:49:39)

Offline

#3 2008-02-03 23:13:56

pyther
Member
Registered: 2008-01-21
Posts: 1,395
Website

Re: Run script from web interface... help?

Edit: Nevermind

Last edited by pyther (2008-02-04 01:41:27)


Website - Blog - arch-home
Arch User since March 2005

Offline

Board footer

Powered by FluxBB