webOS Nation Forums >  webOS apps and software >  webOS development > Running bash/sh scripts from a webos app
Running bash/sh scripts from a webos app

  Reply
 
LinkBack Thread Tools Display Modes
Old 11/05/2009, 05:15 AM   #21 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

bump
DrewPre is offline   Reply With Quote
Old 11/05/2009, 10:38 PM   #22 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

I could use some help on this.... Still having problems accessing a modified version of ipkgservice to run a script command from my application.

could someone, anyone, help out regarding my second to last post?
DrewPre is offline   Reply With Quote
Old 11/10/2009, 01:48 AM   #23 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

Here is an update.

I am attempting to follow rwhitby's advice RE: creating a service.

I created ppbkuservice.java file and compiled it by typing ...
Code:
javac -classpath json.jar;lunaservice.jar;serviceframework.jar;Utils.jar Code.java
This generated a ppbkuservice.class file which I then ran ...
Code:
jar -cvf PPBkuService.jar PPBkuService.class
...against to generate the PPBkuService.jar file. This JAR file I copied to... /usr/lib/luna/java on the emulator

I also created a com.tntservices.ppbkuservice.service file with the following contents...
Code:
[D-BUS Service]
Name=com.tntservices.ppbkuservice
Exec=/usr/bin/luna-helper 'luna://com.palm.vm/launch' '{"serviceName":"com.tntservices.ppbkuservice","className":"com.tntservices.ppbkuservice.PPBkuService"}'
This file I copied to /usr/share/dbus-1/system-services on the emulator

I made sure both files were executable on the Emulator by issuing a CHMOD 755 command against them...

I rebooted the emulator and tried to run the following from the command prompt....

Code:
/usr/bin/luna-send -n 1 palm://com.tntservices.ppbkuservice/version {}
This command should be returning a version number. Instead it gave me the following error....
Quote:
** Message: serviceResponse Handling: 2, {"returnValue":false,"errorCode":-1,"errorText":"Launch helper exited with unknown return code 0"}
As of right now all I have in PPBkuService.java is the following...

Code:
/**
 * 
 */
package com.tntservices.ppbkuservice;

import com.palm.luna.*;
import java.io.*;
import java.util.*;
import org.json.*;

/**
 * @author Drew
 *
 */
public class PPBkuService extends LunaServiceThread {
     private String strVersion = "0.0.1110";

          @LunaServiceThread.PublicMethod
                public void version(ServiceMessage message) {
                      try {
                           StringBuilder sb = new StringBuilder(8192);
                           sb.append("{version:");
                           sb.append(JSONObject.quote(this.strVersion));
                           sb.append("}");
                           message.respond(sb.toString());
                           } 
                           catch (LSException e) {
                                this.logger.severe("", e);
                           }
                }
}
Can someone instruct me on what I am doing wrong??

The luna-send command should be returning a version number of 0.0.1110

[bold]edit:[/bold] FYI - The problem here was the structure of the jar file....the configuration calls for it to be in the com/domain/service folder [e.g. org/webosinternals/ipkgservice] of the Jar file. Mine was on the root of the jar file.

Last edited by DrewPre; 11/12/2009 at 01:21 AM.
DrewPre is offline   Reply With Quote
Thanked By: damnregister
Old 11/10/2009, 02:13 AM   #24 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

In fact I used this same method to install the optloopservice and accelservice that rwhitby directed me to in an earlier post and those services generate the same errors.

I am sure there is something pretty trivial I am overlooking.

help!?
DrewPre is offline   Reply With Quote
Old 11/11/2009, 08:33 PM   #25 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

bump
DrewPre is offline   Reply With Quote
Old 11/12/2009, 12:06 AM   #26 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

I think I've done it.

I have a service and a front-end GUI that backs up, phone, browser, applications, and multimedia to /media/internal/ppbackup in a tarball.

Obvious disk limitations are in place.

As of right now, there is no feed back as to the progress of the backup during the backup. [e.g. You could close the app and the process could still be running.] There are also other bells and whistles to be added. Particularly how to handle if you dont want media or applications backed up. [e.g. adding them to the exclude list]

But the harder work is done.
DrewPre is offline   Reply With Quote
Old 11/12/2009, 12:15 AM   #27 (permalink)
Developer
 
rwhitby's Avatar
 
Join Date: Apr 2003
Location: Adelaide, Australia - follow @webosinternals on Twitter visit www.webos-internals.org and www.facebook.com/webosinternals
Posts: 10,220
Likes Received: 546
Thanks: 90
Thanked 8,534 Times in 2,806 Posts
Default

Quote:
Originally Posted by DrewPre View Post
I think I've done it.

I have a service and a front-end GUI that backs up, phone, browser, applications, and multimedia to /media/internal/ppbackup in a tarball.

Obvious disk limitations are in place.

As of right now, there is no feed back as to the progress of the backup during the backup. [e.g. You could close the app and the process could still be running.] There are also other bells and whistles to be added. Particularly how to handle if you dont want media or applications backed up. [e.g. adding them to the exclude list]

But the harder work is done.
Excellent work. Sorry I haven't had time to help, but I will make time to help you package it up as an app to put in Preware.

-- Rod
__________________
WebOS Internals and Preware Founder and Developer
You may wish to donate by Paypal to donations @ webos-internals.org if you find our work useful.
All donations go back into development.
www.webos-internals.org twitter.com/webosinternals facebook.com/webosinternals
rwhitby is offline   Reply With Quote
Old 11/14/2009, 12:59 PM   #28 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

I can use that help packaging the service files now.

I have a total of 6 files, totalling a whopping 6.44k in the mojo service I created.

I think I am ready for public testing the WebOS application peice. Especially with the release of 1.3.1. I would love to see how a 1.2.1 backup held up on 1.3.1. I've disabled the backing up of multimedia for several reasons. Also there are some known 'issues' like orphaned processes and the app times out when waiting for particularly longer/larger backups, but the backgroung processes complete successfully.

Anyway, I've uploaded the Application and have screenshots of what it looks like but It's still reliant upon the mojo service tho. so you cant do anything until I get the service packaged and uploaded to one of the preware feeds.

Anyway, let me know when you [or anyone] has a chance to help me with the packaging of the service peice.

thx.










Last edited by DrewPre; 04/30/2010 at 05:32 AM.
DrewPre is offline   Reply With Quote
Old 11/14/2009, 01:01 PM   #29 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

oh and keep an eye out for a Pre to Gmail contact migration utility next.
DrewPre is offline   Reply With Quote
Old 11/14/2009, 03:49 PM   #30 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

Heh, I just restored a backup of App, Patches, Contacts, Call Logs, Txt Msgs, Browswer History, and Bookmarks made from a live Pre v1.2.1 onto the 1.3.1 emulator.

after a reboot....

Everything worx so far.
DrewPre is offline   Reply With Quote
Old 11/14/2009, 03:59 PM   #31 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

My application and service appear to work on 1.3.1 as well.

Although I have some more work to do with regard to getting the databases [cookies, depot, & sql] per app backed up so that login info and other settings for apps like mediafly, pandora, and accuweather are retained with their application backups.
DrewPre is offline   Reply With Quote
Old 11/14/2009, 04:49 PM   #32 (permalink)
Developer
 
rwhitby's Avatar
 
Join Date: Apr 2003
Location: Adelaide, Australia - follow @webosinternals on Twitter visit www.webos-internals.org and www.facebook.com/webosinternals
Posts: 10,220
Likes Received: 546
Thanks: 90
Thanked 8,534 Times in 2,806 Posts
Default

Quote:
Originally Posted by DrewPre View Post
I can use that help packaging the service files now.
I've sent you my email address in a private message so we can work on this.

Nice work, BTW.

-- Rod
__________________
WebOS Internals and Preware Founder and Developer
You may wish to donate by Paypal to donations @ webos-internals.org if you find our work useful.
All donations go back into development.
www.webos-internals.org twitter.com/webosinternals facebook.com/webosinternals
rwhitby is offline   Reply With Quote
Old 11/14/2009, 06:37 PM   #33 (permalink)
Member
 
SirataXero's Avatar
 
Join Date: Nov 2007
Location: Rhode Island, USA
Posts: 1,739
Likes Received: 15
Thanks: 381
Thanked 398 Times in 217 Posts
Default

WOW.

That is AMAZING DrewPre!

Unbelievable! I can't even.... I need to pick up a thesaurus to be able to adequately commend you.

I'm very impressed by your drive and your ability to learn all of this and execute it.

I wanted to start something like this by making an app for the GBA Emulator that has been released. However, I don't have the patience (and especially the time) to focus on such a task and see it through to fruition.

In that regards, once again, congrats!

*update*
Hey DrewPre, I've written an article about your exploits here. Let me know if that's cool with you, or if you would like to edit/alter/change it in anyway. Once again, Congrats! Really looking forward to this app.
__________________

Last edited by SirataXero; 11/14/2009 at 10:55 PM.
SirataXero is offline   Reply With Quote
Old 11/14/2009, 11:29 PM   #34 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

I love it! [HUGE SMILE!]

Thank you, for the complements!! It does take a lot of patience, time and perseverence[drive].

The biggest lesson learned: BALANCE

No need banging your head against the wall and keyboard trying to get a square peg in a round hole.

Get up, take a break, get something to eat and come back to the code later. I wasted number of hours trying to jump hurdles that I ended up resolving in 15 minutes after a break.

I guess its a price for being as stubborn as I am.

Thanks for the article. I love it!! [can't stop smiling!! ]

And trust me, I owe Rod W a huge thanks. He did point me in the right direction. Without the two files he referenced at gitorious.org, I would still be scratching my head.


NICE WEBSITE, BTW!

Last edited by DrewPre; 11/14/2009 at 11:53 PM.
DrewPre is offline   Reply With Quote
Old 11/14/2009, 11:32 PM   #35 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

Oh and I suspect they're gonna have me change the name!

Whaddya think?
DrewPre is offline   Reply With Quote
Old 11/14/2009, 11:38 PM   #36 (permalink)
Member
 
Join Date: Jun 2009
Location: Chicago
Posts: 316
Likes Received: 0
Thanks: 32
Thanked 166 Times in 26 Posts
Default

Quote:
Originally Posted by DrewPre View Post
Oh and I suspect they're gonna have me change the name!

Whaddya think?
probably. will your application work with the pixi?
__________________
The Mx Web
kmax12 is offline   Reply With Quote
Old 11/14/2009, 11:38 PM   #37 (permalink)
Developer
 
rwhitby's Avatar
 
Join Date: Apr 2003
Location: Adelaide, Australia - follow @webosinternals on Twitter visit www.webos-internals.org and www.facebook.com/webosinternals
Posts: 10,220
Likes Received: 546
Thanks: 90
Thanked 8,534 Times in 2,806 Posts
Default

FYI, Drew and I have hookup up over email, and I hope to get the service into a Preware feed in the next few days.

-- Rod
__________________
WebOS Internals and Preware Founder and Developer
You may wish to donate by Paypal to donations @ webos-internals.org if you find our work useful.
All donations go back into development.
www.webos-internals.org twitter.com/webosinternals facebook.com/webosinternals
rwhitby is offline   Reply With Quote
Old 11/15/2009, 12:06 AM   #38 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

Thanks, rod.

Max, I don't know... I don't know if the filesystem is the same or not. the 1.3.1 emulator has an option for 320x400 [in addition to 320x480] when starting, suggesting that it emulates the Pixi. But is that the only difference?

I would need a confirmed Pixi emulator. Or Maybe i can get my account manager at Palm to send me a test Pixi! HEH!
DrewPre is offline   Reply With Quote
Old 11/15/2009, 05:14 PM   #39 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

FWIW and for whoever cares....

I was having a problem with the Backup Service orphaning processes [showing up as '< defunct >' in ps -ef ] for the scripts it was running.

It was making calls to Runtime.getRuntime().exec() and this was the method causing the problem.

After some research I added a method Runtime.getRuntime().exec().waitFor() and this resolved the issue.

I mentioned this because I also noticed some defunct processes that were not mine. I suspect other services that were running scripts as well.

Were I to guess I would suggest it was the ipkgservice...I noticed the defunct processes after a restart and ipkgservice seems to be doing quite a lot at bootup.
DrewPre is offline   Reply With Quote
Old 11/15/2009, 05:18 PM   #40 (permalink)
Member
 
DrewPre's Avatar
 
Join Date: Aug 2009
Location: The HARD Streets of Alpharetta, GA
Posts: 829
Likes Received: 2
Thanks: 44
Thanked 176 Times in 92 Posts
Default

Question:

If you have a service that uses scripts that reside somewhere on the filesystem....what is stopping some rogue application from appending to or overwriting that that script with some potentially malicious code of their own, that will be executed the next time that script is run or called upon?
DrewPre is offline   Reply With Quote
Reply

 

Tags
backup app

Thread Tools
Display Modes



 


Content Relevant URLs by vBSEO 3.6.0