webOS Nation Forums >  webOS apps and software >  webOS development > Linking Shellscripts to the Launcher
Linking Shellscripts to the Launcher

  Reply
 
LinkBack Thread Tools Display Modes
Old 02/01/2011, 02:08 PM   #1 (permalink)
Member
 
Join Date: Feb 2011
Posts: 8
Likes Received: 0
Thanks: 0
Thanked 4 Times in 2 Posts
Default Linking Shellscripts to the Launcher

I wasn't sure where to put this, but I think I have the right place..

I want to run a shellscript from Mode Switcher so I can automatically connect to a wireless network that requires you to enter your username and password into a website; I've already written the script, and I'd like to put it as an app into the launcher so I can run it from mode switcher when I connect to the relevant wireless network.

Is this possible, and if yes, would you be kind enough to point me in the right direction?

I did try to work around the problem by putting the script in /etc/network/if-up.d and having it check the SSID, but both times I tried that (after editing /etc/pmnetconfig/if-up) the internet connections on my pre went haywire, which suggests there was something wrong with my script (god knows what, it was only about five lines long), but as the only thing that seemed to fix it was doctoring the pre, I don't much want to keep trying to debug it.
tesseract is offline   Reply With Quote
Old 02/01/2011, 02:56 PM   #2 (permalink)
sq5
Member
 
sq5's Avatar
 
Join Date: Dec 2009
Posts: 471
Likes Received: 38
Thanks: 334
Thanked 73 Times in 64 Posts
Default

I remember seeing in passing long ago that you can't run a shell script from (or as) a WebOS app for security reasons. You might be able to search and find an old thread on this. Someone else chime in if they know for sure.

Last edited by sq5; 02/01/2011 at 03:18 PM.
sq5 is offline   Reply With Quote
Old 02/01/2011, 03:30 PM   #3 (permalink)
Member
 
Join Date: Sep 2010
Posts: 1,836
Likes Received: 89
Thanks: 55
Thanked 323 Times in 228 Posts
Default

I thought this was how some homebrew apps, such as xterm, launched. Yes, xterm can't launch from the launcher as of 1.4.5, but I thought that was more of an issue of the jail configurations in 1.4.5, and not because it launches from a shell script.

Edit: I'm not completely sure if that's the reason why it doesn't work anymore though, so someone who has done this please chime in.
__________________
Grav - Canvas-based Gravity Simulation

Last edited by rsanchez1; 02/01/2011 at 04:09 PM.
rsanchez1 is offline   Reply With Quote
Old 02/01/2011, 04:48 PM   #4 (permalink)
Member
 
Join Date: Jun 2010
Posts: 75
Likes Received: 13
Thanks: 0
Thanked 11 Times in 8 Posts
Default

The backup/restore app in preware uses shell scripts but I don't know how it calls them.
crabbz is offline   Reply With Quote
Old 02/03/2011, 03:50 PM   #5 (permalink)
Member
 
Join Date: Feb 2011
Posts: 8
Likes Received: 0
Thanks: 0
Thanked 4 Times in 2 Posts
Default

Well, thankyou for the contributions; Judging from what you've said (and what I've been able to find on the forums), it's difficult to say the least. So, I'll just try and use if-up and see if I can get it to work.. thankyou
tesseract is offline   Reply With Quote
Old 02/04/2011, 04:20 PM   #6 (permalink)
Member
 
Join Date: Apr 2005
Location: Eindhoven, Netherlands
Posts: 94
Likes Received: 3
Thanks: 16
Thanked 159 Times in 11 Posts
Default

I did more or less the same as you. Have a look here for comparisson:

http://forums.precentral.net/2751620-post18.html

Last edited by robvanvliet; 02/04/2011 at 04:27 PM.
robvanvliet is offline   Reply With Quote
Old 02/04/2011, 04:51 PM   #7 (permalink)
Member
 
Mordac's Avatar
 
Join Date: Aug 2010
Posts: 49
Likes Received: 6
Thanks: 18
Thanked 13 Times in 9 Posts
Default

you could have mode switcher launch terminal, and add your script to the .bashrc file

That would make it run every time terminal runs, though, so checking the ssid would be good.
Mordac is offline   Reply With Quote
Old 02/05/2011, 07:12 AM   #8 (permalink)
Member
 
Join Date: Feb 2011
Posts: 8
Likes Received: 0
Thanks: 0
Thanked 4 Times in 2 Posts
Default

I got it to work using robvanvliet's post, but thankyou anyway
tesseract is offline   Reply With Quote
Old 02/06/2011, 08:28 AM   #9 (permalink)
Member
 
Mordac's Avatar
 
Join Date: Aug 2010
Posts: 49
Likes Received: 6
Thanks: 18
Thanked 13 Times in 9 Posts
Default

Quote:
Originally Posted by tesseract View Post
I got it to work using robvanvliet's post, but thankyou anyway
Good deal!

Would you mind sharing your script to feed username/password into the webpage? I'm in a similar situation and it could be useful.

Thanks,
-M
Mordac is offline   Reply With Quote
Old 02/06/2011, 09:49 AM   #10 (permalink)
Member
 
Join Date: Feb 2011
Posts: 8
Likes Received: 0
Thanks: 0
Thanked 4 Times in 2 Posts
Default

It depends on how the webpage picks up the username/password, but in my case it was trivial, as it passed the variables via POST to another webpage - so I could just use curl:

Code:
#!/bin/bash

ssid=$(iwgetid -s)

if [ -z $ssid ]; then
	exit
fi


if [ $ssid = "DurhamWebAuthentication" ]; then
	curl -k -F fname=wba_login -F username=(username) -F key=(password) https://Durham.Web.Portal/aaa/WebAAA.htm
fi

exit
as in robvanvliet's case, I saved that into /etc/network/if-up.d/ and added a line to the end of /etc/pmnetconfig/if-up to make it run.

Obviously, the variables will be different for your webpage - check the documentation for curl for more information.
tesseract is offline   Reply With Quote
Reply

 

Tags
launcher, shellscript

Thread Tools
Display Modes



 


Content Relevant URLs by vBSEO 3.6.0