Results 1 to 11 of 11

Thread: Tivo module to execute bash script

  1. #1
    Join Date
    Jul 2003
    Posts
    769

    CGI-Like Tivo module to execute bash script

    This is a simple tivoweb module that will execute a bash script and pass parameters to it. I was looking for a way to do cgi on tivoweb and came up with this. Included are sample scripts on how to use it for things like: starting tivoftpd, starting telnet, rebooting tivo and almost anything else you can do from the command line. The bash script I have included shows an HTML menu but it could be anything you want it to be.

    This archive has the script.itcl module file and two example scripts. All you need to do is unzip and extract the included tar file in your modules directory. You can then edit the script.sh file to suite your needs. It's a nice easy way for us non-TCL programmers to add functions to tivoweb without begging or having to learning TCL. You can also make changes to the script without having to reload tivoweb.

    NOTE: I have not tested this extensively although it does work on my Philips SA1/3.0 w/ Tivoweb 1.9.4B4. I have not tried it with any other software combination so YMMV. As always, caveat emptor.

    EDIT: Have since tested with "TivoWebPlus Project - v1.0-rc5" and seems to work okay. It's pretty much brandead simple so it should work with any future versions.


    EDIT2: See below for alternative version by JohnSorTivo with more features.
    Attached Files Attached Files
    Last edited by cojonesdetoro; 04-14-2004 at 02:40 PM.

  2. #2
    Join Date
    Jul 2003
    Posts
    669
    Quote Originally Posted by cojonesdetoro
    This is a simple tivoweb module that will execute a bash script and pass parameters to it. I was looking for a way to do cgi on tivoweb and came up with this. Included are sample scripts on how to use it for things like: starting tivoftpd, starting telnet, rebooting tivo and almost anything else you can do from the command line. The bash script I have included shows an HTML menu but it could be anything you want it to be.

    This archive has the script.itcl module file and two example scripts. All you need to do is unzip and extract the included tar file in your modules directory. You can then edit the script.sh file to suite your needs. It's a nice easy way for us non-TCL programmers to add functions to tivoweb without begging or having to learning TCL. You can also make changes to the script without having to reload tivoweb.

    NOTE: I have not tested this extensively although it does work on my Philips SA1/3.0 w/ Tivoweb 1.9.4B4. I have not tried it with any other software combination so YMMV. As awlays, caveat emptor.
    Now that is just pretty cool... I have been trying to figure out how to do just this exact thing. BTW. Works like a champ on my HDVR2 with Tivoweb Plus...
    Four Hacked HDVR2's,
    One Still slightly confused Hacker,
    4 dogs, 8 cats, and 1 wife that is happy as long as I don't screw up her TiVo ...... Oh yeah two grandchildren that are the light of my life!

  3. #3
    Join Date
    Jul 2003
    Posts
    769
    I have noticed one thing. You have to make sure the script returns control or else it will lock up tivoweb. You'll have to kill the script manually to return control to tivoweb. I think you can avoid this by running a problem command with output to /dev/null and backgrounded like this:

    cmd > /dev/null 2>&1 &

    I had to do this when I used the script to start mfs_ftp. I think may you need to do this for anything that stays running in the background as a deamon process.

  4. #4
    Join Date
    Feb 2004
    Location
    Chicago
    Posts
    877
    Cojonesdetoro,

    I made a quick modification to your RunBash script by adding an input box to allow for the ability to execute any bash command you desire from within TivoWeb, rather than only a fixed set of commands defined in the pre-populated menu.

    It's nothing drastic, and probably not anything that anyone couldn't have done, but since I did it, I thought I would share it nonetheless.

    I find it valuable, for example, when/if you are working on your Tivo remotely, and say for whatever reason your Telnet session (server) hangs, but is still running, but you can no longer connect.

    With the addition of the free-form command entry box, you can issue a 'ps x' command, identify the PID for the telnet server, issue a KILL on the PID, then restart the telnet server, all from within TivoWeb. Which is a real life saver, again,if you can no longer connect via telnet.
    Attached Files Attached Files

  5. #5
    Join Date
    Jul 2003
    Posts
    769
    Quote Originally Posted by JohnSorTivo
    Cojonesdetoro,
    With the addition of the free-form command entry box, you can issue a 'ps x' command, identify the PID for the telnet server, issue a KILL on the PID, then restart the telnet server, all from within TivoWeb. Which is a real life saver, again,if you can no longer connect via telnet.
    Good idea. I'll check it out. The possibilities are endless. It's a nice way to merge the command line with Tivoweb. I'm a shell head and have only recently started doing some TCL stuff so this is great for me.

    BTW, Here's an Expect script that enforces a timeout on a running process so it returns control to the parent process. This would help with modules that lock up tivoweb:

    http://www.dealdatabase.com/forum/sh...ad.php?t=32755

    I never got any feedback so I'm not sure how well it works in other environments.
    perl -e 'print unpack("u","\@2\&\%V92\!Y;W4\@:&\%C:V5D(\%E/55\(\@5\&EV\;R\!T;V1A>3\\-\`"),"\n";'

  6. #6
    Join Date
    Jan 2004
    Location
    Chebeague Island, Maine
    Posts
    812
    Does anybody have any ideas why it doesn't like to execute an alias? Or how to make it do so?
    David R. Hill............... TivoWeb Hack Manager
    Chebeague Island........From the land of champions:
    Casco Bay..................The Boston Red Sox
    Maine........................The New England Patriots
    58.5 gig HDR-112 since October, 2000
    240 gig, 306 hours since January, 2004 (same machine)
    120 gig DSR6000 DirecTiVo

    "There are 10 kinds of people -- those who count in binary and those who don't."

  7. #7
    Join Date
    Jul 2003
    Posts
    769
    Where are the aliases stored? I keep mine in ${HOME}/.bashrc. Given that, I think you you can load your aliases with this statement in your script:

    Code:
    . ${HOME}/.bashrc
    Keep in mind that whatever you have in the bashrc file may also affect your script in other ways. For example, I have a 'cd /var/hack' command in mine so if I needed my aliases I would just put the ones I need into the script directly. Another option is to create yet another exclusive script for all your aliases called by bashrc et al.
    perl -e 'print unpack("u","\@2\&\%V92\!Y;W4\@:&\%C:V5D(\%E/55\(\@5\&EV\;R\!T;V1A>3\\-\`"),"\n";'

  8. #8
    Join Date
    Jan 2004
    Location
    Chebeague Island, Maine
    Posts
    812
    Quote Originally Posted by cojonesdetoro
    Where are the aliases stored? I keep mine in ${HOME}/.bashrc. Given that, I think you you can load your aliases with this statement in your script:

    Code:
    . ${HOME}/.bashrc
    I get a "stty: standard input: Inappropriate ioctl for device" error. Not really a big deal, but just curious how this approach to the bash is working.
    David R. Hill............... TivoWeb Hack Manager
    Chebeague Island........From the land of champions:
    Casco Bay..................The Boston Red Sox
    Maine........................The New England Patriots
    58.5 gig HDR-112 since October, 2000
    240 gig, 306 hours since January, 2004 (same machine)
    120 gig DSR6000 DirecTiVo

    "There are 10 kinds of people -- those who count in binary and those who don't."

  9. #9
    Join Date
    Jul 2003
    Posts
    769
    Probably some command you're running in the .bashrc. Do some trial-and-error

    EDIT: The message has to do with something that needs to talk to a terminal (or tty). The script runs not associated with a tty. If this presents a problem, you can use Expect, which 'pretends' to be a real interactive user at a tty.
    Last edited by cojonesdetoro; 03-18-2004 at 10:56 PM.
    perl -e 'print unpack("u","\@2\&\%V92\!Y;W4\@:&\%C:V5D(\%E/55\(\@5\&EV\;R\!T;V1A>3\\-\`"),"\n";'

  10. #10
    Join Date
    Jan 2004
    Location
    n.h. usa
    Posts
    958
    thanks strange thing I had to change the following line but my /var/local/tivoweb-tcl is not read only but it was complaining that it couldn't write because the file system was read only... change the line as follows and it runs ok...

    # puts $chan [ exec $bashscript $params $q 2>&1 ]
    puts $chan [ exec $bashscript $params $q ]


    my guess is it is because tivoweb was run from /etc/rc.d which is read only so I probably should add the line back in fully qualified or somthing what do you think...

  11. #11
    Join Date
    Jul 2003
    Posts
    769
    Removing the 2>&1 would rpevent you from seeing errors generated by the bashscript from within Tivoweb. I'm not sure why you would encounter a read-only error message with it included... What is in your bash script?
    perl -e 'print unpack("u","\@2\&\%V92\!Y;W4\@:&\%C:V5D(\%E/55\(\@5\&EV\;R\!T;V1A>3\\-\`"),"\n";'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •