Home | Stories | Reviews | Treo™ Store | Accessories | Software | Discussion | Mobile | About | Search

 
 
 Leather Side Case Palm Side Case
Just $24.95
H17 Bluetooth Headset Motorola H17 Bluetooth Headset
Just $89.95
HS-500 Bluetooth Headset BlackBerry HS-500 Bluetooth Headset
Just $69.95
Micro-USB Travel Charger SPE Micro-USB Travel Charger for Palm Pixi / Treo Pro, Treo 800w
Just $9.95
 
Old 10/31/2009, 05:07 AM   #1 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 441
Thanks: 31
Thanked 71 Times in 38 Posts
Default Running bash/sh scripts from a webos app

I've created a webos app. The UI is just the way I want it. The only thing left is to run a shell script, that I have also created and confirmed works. And to do so from a button in the webos app.

Is there a way in javascript or html to launch the shell script? The open method of the appMgr only seems to work with registered apps and mime types which won't work for shell scripts.

Am I going about this all the wrong way?

I need ideas people!!!

hehehe!
DrewPre is offline   Reply With Quote
Old 10/31/2009, 05:10 AM   #2 (permalink)
ird
Member
 
Join Date: Jul 2009
Posts: 92
Thanks: 0
Thanked 10 Times in 7 Posts
Default

I'm guessing since Preware uses scripts to install certain parts of apps, patches, etc. That the package manager service has some way to execute them.
ird is offline   Reply With Quote
Old 10/31/2009, 05:33 AM   #3 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 441
Thanks: 31
Thanked 71 Times in 38 Posts
Default

Yea, I thought so too, but I guess I needed someone to translate/interpret the assistants files for me. There isn't exactly any tutorials for them.

Reading those files were like reading greek.
DrewPre is offline   Reply With Quote
Thanked By:
Old 10/31/2009, 07:06 AM   #4 (permalink)
Developer
 
rwhitby's Avatar
 
Join Date: Apr 2003
Location: Adelaide, Australia - follow @webosinternals on Twitter and read the wiki at www.webos-internals.org
Posts: 1,800
Thanks: 22
Thanked 1,214 Times in 367 Posts
Default

A mechanism that allowed a webOS app to run any shell command it wanted to would be a HUGE security hole.
You need to write a service which does exactly and only what you need it to do, and carefully review it so that it doesn't open up any security vulnerabilities.
See git.webos-internals.org for example services.

-- Rod
__________________
WebOS Internals and Preware Founder and Developer
You may wish to
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
if you find my work useful. All donations go back into development.
rwhitby is online now   Reply With Quote
Old 10/31/2009, 08:07 AM   #5 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 441
Thanks: 31
Thanked 71 Times in 38 Posts
Default

yea, I took a look at some of the src code for a few of thoses services....it's way above my head. How would one get started writing a service? What are the pre-reqs for learning that kinda stuff?
DrewPre is offline   Reply With Quote
Thanked By:
Old 10/31/2009, 08:18 AM   #6 (permalink)
Developer
 
rwhitby's Avatar
 
Join Date: Apr 2003
Location: Adelaide, Australia - follow @webosinternals on Twitter and read the wiki at www.webos-internals.org
Posts: 1,800
Thanks: 22
Thanked 1,214 Times in 367 Posts
Default

Quote:
Originally Posted by DrewPre View Post
yea, I took a look at some of the src code for a few of thoses services....it's way above my head. How would one get started writing a service? What are the pre-reqs for learning that kinda stuff?
At the moment, you need to know Java.

In the future, knowing C will be enough.

Knowing Makefiles will be an advantage for either.

-- Rod
__________________
WebOS Internals and Preware Founder and Developer
You may wish to
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
if you find my work useful. All donations go back into development.
rwhitby is online now   Reply With Quote
Old 10/31/2009, 08:26 PM   #7 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 441
Thanks: 31
Thanked 71 Times in 38 Posts
Default

I don't know C or Make files...

I don't know JAVA either... but I took the time to search and teach myself just enough to do this.....

I also went in a different direction and created this app for the Palm Pre.

I created these two apps to have two options to perform the same tasks....So I am not completely clueless when it comes to coding.


I am not asking anyone to spoon feed me but point me in the right direction, please.
DrewPre is offline   Reply With Quote
Thanked By:
Old 10/31/2009, 08:31 PM   #8 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 441
Thanks: 31
Thanked 71 Times in 38 Posts
Default

Okay maybe I AM asking for someone to spoon feed me. It would be nice if you could put a bib on me and burp me when you're done!!

I have the time and motivation right now and I want to learn this stuff.
DrewPre is offline   Reply With Quote
Thanked By:
Old 10/31/2009, 08:40 PM   #9 (permalink)
Developer
 
rwhitby's Avatar
 
Join Date: Apr 2003
Location: Adelaide, Australia - follow @webosinternals on Twitter and read the wiki at www.webos-internals.org
Posts: 1,800
Thanks: 22
Thanked 1,214 Times in 367 Posts
Default

Quote:
Originally Posted by DrewPre View Post
I don't know C or Make files...

I don't know JAVA either... but I took the time to search and teach myself just enough to do this.....

I also went in a different direction and created this app for the Palm Pre.

I created these two apps to have two options to perform the same tasks....So I am not completely clueless when it comes to coding.


I am not asking anyone to spoon feed me but point me in the right direction, please.
git.webos-internals.org Git - services/accelservice.git/blob - AccelService.java and git.webos-internals.org Git - services/optloopservice.git/blob - OptLoopService.java are the simplest Java services there are at the moment.

What exactly do you need the service to do?

-- Rod
__________________
WebOS Internals and Preware Founder and Developer
You may wish to
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
if you find my work useful. All donations go back into development.
rwhitby is online now   Reply With Quote
Old 10/31/2009, 09:04 PM   #10 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 441
Thanks: 31
Thanked 71 Times in 38 Posts
Default

well at the moment, just want the service to call a shell script that I have already created that when passed a couple of parameters [e.g. which directories to backup] will identify the directorys existence adn then tarball them and move them to media/internal.

further down the line, I would like to add an option to export contacts to CSV file, and this to I already have a shell script for.

So again, at the moment, I just need the service to launch a shell script and the ability to pass it a few parameters.

Gonna check out your links now.....
DrewPre is offline   Reply With Quote
Old 10/31/2009, 09:06 PM   #11 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 441
Thanks: 31
Thanked 71 Times in 38 Posts
Default

Oh and I guess the ability to get success or failure codes back from the script.
DrewPre is offline   Reply With Quote
Old 11/01/2009, 02:56 AM   #12 (permalink)
Member
 
Join Date: Jun 2009
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Default

You should check out MyFlashlight, in the homebrew section. He wrote a service to do exactly this!
Godsbane is offline   Reply With Quote
Old 11/01/2009, 03:00 AM   #13 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 441
Thanks: 31
Thanked 71 Times in 38 Posts
Default

Okay I think I have formulated something that resembles a java service based on the executeCMD found in the optLoop service link you provided.

However, I have no way of testing it. I just spent about an hour trying to figure out how to load jdk on the emulator only to find that the emulator doesn't have enuff hdd space and even after add/mounting a 2gb vdd to the emulator and copying the jdk installer to it and running it I get errors.

So I am at a lose as to how to compile this in the emulator and test it. I could use some help in setting up my emulator for a development environment.
DrewPre is offline   Reply With Quote
Thanked By:
Old 11/01/2009, 03:15 AM   #14 (permalink)
Developer
 
rwhitby's Avatar
 
Join Date: Apr 2003
Location: Adelaide, Australia - follow @webosinternals on Twitter and read the wiki at www.webos-internals.org
Posts: 1,800
Thanks: 22
Thanked 1,214 Times in 367 Posts
Default

Quote:
Originally Posted by Godsbane View Post
You should check out MyFlashlight, in the homebrew section. He wrote a service to do exactly this!
Yes, and (previous to Jason Robitaille rewriting it) it was a huge security vulnerability, effectively allowing any rogue web OS app to do anything as the root user that it pleases on your Pre.

-- Rod
__________________
WebOS Internals and Preware Founder and Developer
You may wish to
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
if you find my work useful. All donations go back into development.
rwhitby is online now   Reply With Quote
Old 11/01/2009, 03:18 AM   #15 (permalink)
Developer
 
rwhitby's Avatar
 
Join Date: Apr 2003
Location: Adelaide, Australia - follow @webosinternals on Twitter and read the wiki at www.webos-internals.org
Posts: 1,800
Thanks: 22
Thanked 1,214 Times in 367 Posts
Default

Quote:
Originally Posted by DrewPre View Post
Okay I think I have formulated something that resembles a java service based on the executeCMD found in the optLoop service link you provided.

However, I have no way of testing it. I just spent about an hour trying to figure out how to load jdk on the emulator only to find that the emulator doesn't have enuff hdd space and even after add/mounting a 2gb vdd to the emulator and copying the jdk installer to it and running it I get errors.

So I am at a lose as to how to compile this in the emulator and test it. I could use some help in setting up my emulator for a development environment.
Take a look at the Eclipse project file in ipkgservice. We have a build.xml file in there which does the upload of the .jar file to the right place on the Pre and triggers the restart of the upstart control file to enable it.

That's how I test the Package Manager Service - compile and jar it on the host (a MacBookPro in my case) and scp it to the Pre.

-- Rod
__________________
WebOS Internals and Preware Founder and Developer
You may wish to
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
if you find my work useful. All donations go back into development.
rwhitby is online now   Reply With Quote
Old 11/01/2009, 03:42 AM   #16 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 441
Thanks: 31
Thanked 71 Times in 38 Posts
Default

That's another thing.....

Do you scp it to your Pre or your Emulator?

I can't seem to get a ping-able ip address for my emulator. I can ping my host from the emu, but I can't ping the emu from the host.

iptables and PS doesn't show a firewall running. The host shows up as 192.168.56.x and the emu as 10.0.2.x and no matter what I do I can't ping the emu from the host. I even tried adding a persistent route to the host. Didn't work!

I can novaterm into the emu but I would like to use SSH Secure Shell to connect instead. I made sure the ssh client was trying to connect to port 2222 but.... nothing.
DrewPre is offline   Reply With Quote
Thanked By:
Old 11/01/2009, 04:02 AM   #17 (permalink)
Developer
 
rwhitby's Avatar
 
Join Date: Apr 2003
Location: Adelaide, Australia - follow @webosinternals on Twitter and read the wiki at www.webos-internals.org
Posts: 1,800
Thanks: 22
Thanked 1,214 Times in 367 Posts
Default

Quote:
Originally Posted by DrewPre View Post
That's another thing.....

Do you scp it to your Pre or your Emulator?

I can't seem to get a ping-able ip address for my emulator. I can ping my host from the emu, but I can't ping the emu from the host.

iptables and PS doesn't show a firewall running. The host shows up as 192.168.56.x and the emu as 10.0.2.x and no matter what I do I can't ping the emu from the host. I even tried adding a persistent route to the host. Didn't work!

I can novaterm into the emu but I would like to use SSH Secure Shell to connect instead. I made sure the ssh client was trying to connect to port 2222 but.... nothing.
I scp to the emulator.

I add a second network interface in VirtualBox, and set it to host-only vboxnet0 - this gives me a private 192.168.58.x subnet on which both the host and all the virtualbox VMs live (handy for scp'ing from the Ubuntu virtual machine to the Pre or Pixi virtual machines).

Then I install optware on the emulator using the bootstrap script, and set it up for scp access over the 192.168.56.x interface (you have to modify /etc/network/interfaces on the emulator to enable the second network interface and allow to to get an address from the host using DHCP).

-- Rod
__________________
WebOS Internals and Preware Founder and Developer
You may wish to
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
if you find my work useful. All donations go back into development.
rwhitby is online now   Reply With Quote
Old 11/01/2009, 04:17 AM   #18 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 441
Thanks: 31
Thanked 71 Times in 38 Posts
Default

I used novaterm to go through the bootstrap script but it never prompted me to setup a new/additional user like it did on my real Pre. I've run and Re-run it and I could never get it to prompt me for taht additional user.

no errors are displayed tho. And it completes saying that ssh and scp are set up....and I can see a dropbear process in PS but there is no optware-dropbear startup file in /etc.... so I have no idea if it has launched with the -g parameter to disable root logins.

So that could be preventing me from logging in also.

Update: Scratch all that, I am in.
DrewPre is offline   Reply With Quote
Thanked By:
Old 11/01/2009, 04:55 AM   #19 (permalink)
Developer
 
rwhitby's Avatar
 
Join Date: Apr 2003
Location: Adelaide, Australia - follow @webosinternals on Twitter and read the wiki at www.webos-internals.org
Posts: 1,800
Thanks: 22
Thanked 1,214 Times in 367 Posts
Default

Quote:
Originally Posted by DrewPre View Post
I used novaterm to go through the bootstrap script but it never prompted me to setup a new/additional user like it did on my real Pre. I've run and Re-run it and I could never get it to prompt me for taht additional user.

no errors are displayed tho. And it completes saying that ssh and scp are set up....and I can see a dropbear process in PS but there is no optware-dropbear startup file in /etc.... so I have no idea if it has launched with the -g parameter to disable root logins.

So that could be preventing me from logging in also.

Update: Scratch all that, I am in.
Yeah, on the emulator the optware bootstrap script doesn't bother with another user and just sets up root access.

-- Rod
__________________
WebOS Internals and Preware Founder and Developer
You may wish to
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
if you find my work useful. All donations go back into development.
rwhitby is online now   Reply With Quote
Old 11/04/2009, 03:37 AM   #20 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 441
Thanks: 31
Thanked 71 Times in 38 Posts
Default

I added the code below to the corresponding sections of the ipkgservice.java file of the ipkgservice service that you instructed me to look at.

I then installed it in my emulator and then I modified my Palm Backup Util's main-assistant.js file to look like the doRescan function of the Luna Manager app. My assumption is that the startButton function in my Palm Pre Backup app should act just like the doRescan function of the Luna Manager app. In that they put in a call to ipkgservice to run 'backup' and 'rescan' respectively.

Apparently this is a wrong assumption. It does not execute the script that I have told it to....

Code:
   private JSONObject startButton(ServiceMessage msg)
	throws JSONException, LSException {
	JSONObject reply = new JSONObject();
	ReturnResult ret = executeCMD("/opt/bin/ppbku");
	reply.put("returnValue",(ret.returnValue == 0));
	reply.put("stdOut", ret.stdOut.toString());
	reply.put("stdErr", ret.stdErr.toString());
	if (ret.returnValue!=0) {
	    reply.put("errorCode", ErrorMessage.ERROR_CODE_METHOD_EXCEPTION);
	    reply.put("errorText", "Failure during 'Backup' operation");
	}
	return reply;
    }
Code:
    @LunaServiceThread.PublicMethod
	public void backup(ServiceMessage msg)
	throws JSONException, LSException {
	JSONObject reply = startButton(msg);
	msg.respond(reply.toString());
    }
Of course the Main-Assistant.js of the Palm Pre Backup app looks like ....

Code:
MainAssistant.prototype.continueBtn = function(event) 
{
	try
	{
		this.controller.get("announcement").update("Processing...");
		this.controller.stageController.pushScene('process', this.checkboxBRModel, this.checkboxPDModel);
		var r = new Mojo.Service.Request
		(
			'palm://org.webosinternals.ipkgservice',
			{
				method: 'backup',
				onSuccess: this.callbackFunction.bindAsEventListener(this, 'Backup'),
				onFailure: this.callbackFunction.bindAsEventListener(this, 'Backup')
			}
		);
	}
	catch (e)
	{
		Mojo.Log.logException(e, 'main#continueBtn');
		this.alertMessage('main#continueBtn Error', e);
	}	
}
DrewPre is offline   Reply With Quote
Reply


Thread Tools
Display Modes

~


All times are GMT -4. The time now is 07:27 PM.

Creating smartphone communities
Android Central - Android reviews, news and forums Crackberry - Blackberry news, reviews and community TiPb - iPhone news, accessory reviews & forums
Pre Central - Palm Pre Review, News and Community Treo Central - Treo & Centro News and Forums WMExperts - Windows Mobile Reviews & News

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
 
 

Copyright ©1999- TreoCentral. All rights reserved : Terms of Use : Privacy Policy

TREO and TreoCentral are trademarks or registered trademarks of palm, Inc. in the United States and other countries;
the TreoCentral mark and domain name are used under license from palm, Inc.
The views expressed on this website are solely those of the proprietor, or
contributors to the site, and do not necessarily reflect the views of palm, Inc.

Explore More: Crackberry | WMExperts | the iPhone Blog | Android Central | Smartphone Experts Combined Forums