bash scripts to upload and delete from the roku menu

“destruk” wrote:
I thought the rollseyes icon would get a point across. It’s really cool there are so many ways to get this to work, but I think everyone would be really super impressed if we could see the pure assembly language bytes to make it do this too - maybe you can type that up. :slightly_smiling_face:
oh if I misinterpreted your remarks, sorry.

I use a mac, and in addition to my ~/.bash_profile which has the ROKU_DEV_TARGET, I have two copies named after the ip address (I assign a fixed address from my router based on the mac addr), one each with a different target. When I want to upload I just type:

source ~/.67
make install

for roku A

source ~/.69
make install

for roku B

Nice and simple. The reason one doesn’t want to use the web interface becomes clear when you do hundreds of builds and tests per day, you would get carpel tunnel in a week.

  • Joel

“jbrave” wrote:

source ~/.67
make install

You can save a few keystrokes by typing “.” (a single dot) instead of “source”.

–Mark

“jbrave” wrote:
I use a mac, and in addition to my ~/.bash_profile which has the ROKU_DEV_TARGET, I have two copies named after the ip address (I assign a fixed address from my router based on the mac addr), one each with a different target. When I want to upload I just type:

source ~/.67
make install

for roku A

source ~/.69
make install

for roku B

Nice and simple. The reason one doesn’t want to use the web interface becomes clear when you do hundreds of builds and tests per day, you would get carpel tunnel in a week.

  • Joel
    I think this is one of those culture things I dont get because although I have years of coding I avoided coding C.
    now I can do ./configure; make; make install with the best of them. but making my own make files was something I always left to the c guys. I would write a script to do whatever the make file didn’t. always have. Maybe its from having to administer thousands of boxes, I think how do I script around what someone else has forgotten to do or to customize to my situation instead of modifying the make file. Still don’t think its as clean but it makes more sense now thanks to kbenson. I am going to finish the command line interface for the web interface. I am sure someone will use it. maybe some linux lurker. I may make a command line that looks for rokus on the network and creates a script to automatically “make” them to all rokus on the network or give you a choice of which ones. that script will use the environment variable.

“jbrave” wrote:

Nice and simple. The reason one doesn’t want to use the web interface becomes clear when you do hundreds of builds and tests per day, you would get carpel tunnel in a week.

  • Joel

Thats Funny Joel, its not that bad its how i do it and have been doing it since last summer. I don’t want to get the same treatment as destruk because i know i am not qualified to talk about this, as a windows user i just go to the webpage, i honestly can’t see how it is that much simpler than a click of the mouse, of course as a windows user not sure we have any other choice.

“dynamitemedia” wrote:

“jbrave” wrote:

Nice and simple. The reason one doesn’t want to use the web interface becomes clear when you do hundreds of builds and tests per day, you would get carpel tunnel in a week.

  • Joel

Thats Funny Joel, its not that bad its how i do it and have been doing it since last summer. I don’t want to get the same treatment as destruk because i know i am not qualified to talk about this, as a windows user i just go to the webpage, i honestly can’t see how it is that much simpler than a click of the mouse, of course as a windows user not sure we have any other choice.
come on guys. This is not a windows vs linux thing. I dont judge the quality of your VB script because I am unqualified to do so and vice versa. That is what I meant. As a linux guy, you wont hear me saying something like “you used windows scripting host for that, what a hack”, because I dont know if its a good choice or not.
But I do agree with Joel. My point in doing this is to make a script for my editor so when I am done with some brightscript I can hit an option in my editor and it will run a script and package up the brightscript and send it to all my rokus’s(all two of them) in one fell swoop.

“dynamitemedia” wrote:

of course as a windows user not sure we have any other choice.
I am not trying to be snarky on this, but you do have a choice. Cygwin(http://www.cygwin.com/).
They have a bash shell and you could take that code and run it on a windows machine in theory. I have taken some pretty complex bash scripts and ran them in windows before. You just have to make sure you dont use linux only stuff like writing files to /tmp in widows thats normally c:\temp if I remember correctly. What I do is write it to a temp dir underneath the current one. that way it will work in both. then I delete that dir.
But I digress, check out cygwin, I think all the scripts I posted here will work in cygwin. If you try one out and it doesn’t work say so and I will fix it so it does.
If you make a roku related script in C# I would appreciate it if you would make it work in mono.
This is what being part of a community is about, we work together to make it stronger as a whole, not just our faction.

Cygwin is one way to get the job done, certainly. And it adds a lot of other benefits. But if you don’t have any other need for it, the Windows XP command line (and a few other tools built for Win32/64) are more than capable enough to do the same work as the configure/make/install tools, for the purposes of packaging and installing Roku channels. I put the following into my “SendTo” menu (C:\Users\USER_NAME\AppData\Roaming\Microsoft\Windows\SendTo in Windows 7) and also have something similar installed as a command macro in my code editor. Then I can click on the folder icon my code lives in (the directory above the manifest) and “Send To…>Roku”; or I can have the manifest open in my editor and simply hit a shortcut key there to install.

7z %1.zip %1\*
curl -s -S -F "archive=@%1.zip" -F "mysubmit=Replace"  http://192.168.1.10/plugin_install
pause

Curl is available here: http://curl.haxx.se/download.html (I use the win32 2000/XP binary with ssl, it’s most of the way down the page)
7Zip is here: http://www.7-zip.org/download.html

I have to look into adding the possibility of leaving the pngs uncompressed, now that I know about it. :slightly_smiling_face: I could also easily replace the hardcoded IP with an environment variable, but I only have one box I am using for development, and my addresses are stable thanks to dhcp reservations on the router.

Dynamitemedia(and destruk), what is your development environment like(OS and editor)? It can probably be adapted to more automatically build and install your channel changes and save you time as you develop. After you get it set up and working, and you can compare how effortless it is compared to the manual process, you’ll probably agree with everyone else that it was worth it :). The more options developers have, be it windows, mac, linux, or other, the better!

“gonzotek” wrote:
Cygwin is one way to get the job done, certainly. And it adds a lot of other benefits. But if you don’t have any other need for it, the Windows XP command line (and a few other tools built for Win32/64) are more than capable enough to do the same work as the configure/make/install tools, for the purposes of packaging and installing Roku channels. I put the following into my “SendTo” menu …
Dynamitemedia(and destruk), what is your development environment like(OS and editor)? It can probably be adapted to more automatically build and install your channel changes and save you time as you develop. After you get it set up and working, and you can compare how effortless it is compared to the manual process, you’ll probably agree with everyone else that it was worth it :). The more options developers have, be it windows, mac, linux, or other, the better!
This is what I am talking about, a well thought out response that helps expands all our knowledge.
Thanks gonzotek, I am for automation no matter what the OS.

“gonzotek” wrote:

Dynamitemedia(and destruk), what is your development environment like(OS and editor)? It can probably be adapted to more automatically build and install your channel changes and save you time as you develop. After you get it set up and working, and you can compare how effortless it is compared to the manual process, you’ll probably agree with everyone else that it was worth it :). The more options developers have, be it windows, mac, linux, or other, the better!

i have said here many times i use windows, i understand your guys intentions and that great. but i am ok with the 2-5 seconds of click browse and upload. I am not in that much of a hurry.

“manoflinux” wrote:
My point in doing this is to make a script for my editor so when I am done with some brightscript I can hit an option in my editor and it will run a script and package up the brightscript and send it to all my rokus’s(all two of them) in one fell swoop.

I would love to have my editor (jedit) run a make install whenever I save, actually. I’m sure there is a way to do it.

-Joel

“dynamitemedia” wrote:
i have said here many times i use windows, i understand your guys intentions and that great. but i am ok with the 2-5 seconds of click browse and upload. I am not in that much of a hurry.Hey, it’s your rig, do what you like. :slightly_smiling_face: But there’s always room for improvement, and if you wanted to try (or someone else does), I was looking for specifically what version of windows(the “Send to” folder is in different places under XP, Vista and 7) and what editor for coding do you use? For instance, I use Crimson Editor (and sometimes Notepad++) under Windows 7. I know, for me, because I am not very comfortable with Brightscript, when I am trying things, I am constantly changing a small piece of code over and over until I get the results I want, and I might do as many as 30 (just slightly different) versions in an hour. Switching away from my editor to zip in explorer, then upload in the browser, takes both my time and my concentration away from the goal of improving my code.

“jbrave” wrote:

“manoflinux” wrote:
My point in doing this is to make a script for my editor so when I am done with some brightscript I can hit an option in my editor and it will run a script and package up the brightscript and send it to all my rokus’s(all two of them) in one fell swoop.

I would love to have my editor (jedit) run a make install whenever I save, actually. I’m sure there is a way to do it.

-JoelLooks like you could write a macro to save, then zip and upload. The jedit user’s guide has details: http://www.jedit.org/users-guide/index.html
And here’s a blog post that looks helpful: http://hasseg.org/blog/post/96/jedit-ma … compilers/

all that arguing and at least one person got help, at least indirectly. wonderful.
its always good to brainstorm about a subject publicly, no telling what sort of solutions will come out of it.

if you have root and are at home you can do this to show all the rokus on the network, just replace 192.168.0.* with your network info.
sudo nmap -O 192.168.0.*|grep “MAC Address:|report for”|grep -i -B 1 roku

And yes you windows guys can do this to. http://nmap.org/book/inst-windows.html
just don’t do it at work. and if you do don’t blame me if you get a visit from your network admin.
If you are the network admin, don’t worry about it. :wink:

here is a program to package a script up and download the package from the “Application Packager” menu.


packageroku ()
{
uagent='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
ftime=$(($(date +'%s')*1000)) ;
if [ "$1" ] && [ "$2" ] && [ "$3" ] && [  ${#1} -lt 32 ]; then 
  purl=$(curl --silent --show-error --user-agent "$uagent" --form "app_name=$1" --form "passwd=$2" --form "pkg_time=$ftime" --form "mysubmit=Package" "http://$3/plugin_package" |grep "href"|grep -v "plugin_inspect\|plugin_install"|awk -F 'href="' '{ print $2 }'|tr '"' '\n'|head -n1  :wink:  ;
  wget http://$3/$purl ;
else
  echo -e "app name too large or two few arguments format is\npackageroku appname dev_password IPaddress_of_ROKU ";  
fi
}

example use:
just replace roku01.local the ip of your roku if you dont have a name for it.


$delroku roku01.local
Delete Succeeded.
$uproku videoplayer.zip roku01.local
Application Received: 127030 bytes stored.
size on disk is 127030 bytes 
$packageroku 'sample video player' 'your_dev_password' roku01.local
--2011-04-29 13:50:24--  http://roku01.local/pkgs/somepackage.pkg
Resolving roku01.local... 192.168.0.24
Connecting to roku01.local|192.168.0.24|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 130000 (127K) [text/plain]
Saving to: `somepackage.pkg'

100%[==========================================================================================>] 130,000     --.-K/s   in 0.02s   

2011-04-29 13:50:24 (5.25 MB/s) - `somepackage.pkg' saved [130000/130000]

For testing purposes, I probably do an actual build of a channel once per week. It’s a handful of channels, and I test through my code a lot before I even put it on a box or package it. I use NOTEPAD/windows, ha, oldschool me, has the features I need, and zip it up after I verify logic and that works for me. I use notepad for building the web server/php, notepad for the manifest, I changed all the rich text files into actual unicode files for notepad too. And the webpage works fine too. So I’m probably underqualified to even touch linux, but I have my own system and time isn’t an issue as I don’t mass install to thousands of boxes at a single go either…perhaps I’m just too stupid to change old habits. :slightly_smiling_face: I do write scripts to do routine database operations like backup and restore, and php scripts to create/clear tables in mysql, and I do use ubuntu on a limited basis for alternate projects unrelated to roku with a hotswap drive bay, but I really don’t want to go all lowlevel sudo techno ninja on using bash shell scripts - that’s just my own choice as my brain has to hold a whole lot of relevant info on other topics.

thats fine, its a free country. use windows or Linux or BeOS or MorphOS or whatever.
I am sure there are people that will disagree with you and want some sort of automation.
But I am also sure there are people that agree with you.
Those people dont have to use mine or gonzo’s ideas. I just think you would have an easier time if you did.
But you disagree and we can leave it at that.

I have said it before these scripts are just part of a whole package I am building to integrate brightscript development into kate.
Once I got that done I can start learning brightscript in better detail. Since I will then have an effortless Dev environment it will make my task much easier. .

why don’t you just try to learn brightscript? i also learned(?) using notepad and the debugger.

seems like your wasting more time trying to automate it or find an easier way then actually learn it. wouldn’t be more effective learning brightscript and then learn how to automate it?

“dynamitemedia” wrote:
why don’t you just try to learn brightscript? i also learned(?) using notepad and the debugger.

seems like your wasting more time trying to automate it or find an easier way then actually learn it. wouldn’t be more effective learning brightscript and then learn how to automate it?Separate issues. I think you’ll find many professional and amateur coders will agree that using a source code editor can make you more productive, regardless of the language being used. I’ll crib from wikipedia’s article:
Source code editors have features specifically designed to simplify and speed up input of source code, such as syntax highlighting, autocomplete and bracket matching functionality. These editors also provide a convenient way to run a compiler, interpreter, debugger, or other program relevant for software development process. So, while many text editors can be used to edit source code, if they don’t enhance, automate or ease the editing of code, they are not “source code editors,” but simply "text editors that can also be used to edit source code."Learning the language is clearly extremely important as well. But what manoflinux is doing here isn’t only for himself. Once he completes his goal, anyone who uses the kate editor should have an easier time beginning with brightscript.

As an example of what source editors can do: Winamp has a scripting language for skinning, called Maki. Years ago, I created syntax highlighting rules files for Maki code for the Windows editor Crimson Editor, and submitted them to the Crimson Editor developer, who put them into the official releases. Now you can open up any maki script in crimson editor and have syntax highlighting making objects, methods, strings and constants stand out from one another. This makes it much easier to read the code, especially if it’s someone else’s code you aren’t yet familiar with. I thought about doing the same for Brightscript, but Crimson Editor is kind of a dead project (although even without any major new features in several years, it’s still very good ) and I don’t think I could get the syntax files included in it like I did for Maki. I suppose I could host them and give people instructions on how to install them manually.