Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-24-2009, 10:25 AM   #1 (permalink)
New Member
 
Join Date: Jun 2009
Posts: 4
rocomotion is on a distinguished road
Question Running a shell script from Ipod Touch App

Sorry for spamming this on like all the iPhone Dev forums, but...well I can't find any info on it, and I'd like to know before I shell out to buy a mac for the iPhone SDK. Basically I am wondering if it is possible to run a console script (.sh) from an iPhone App. The script is written to download a program from a repository that I set up, respring, then after a set time delete the program and respring again, so it needs root privileges, and is interactive in that the user can set how long the program will be kept. I have the bash script written, and it works fine when called from mobile terminal, but is there any way to do this from within a (jailbroken) app (without using mobile terminal / SSH / Bossprefs)? Or is there an overall better way to achieve this?
Thanks
rocomotion is offline   Reply With Quote
Old 06-30-2009, 07:44 AM   #2 (permalink)
Alx
New Member
 
Join Date: Jan 2009
Posts: 11
Alx is on a distinguished road
Wink

Quote:
Originally Posted by rocomotion View Post
Sorry for spamming this on like all the iPhone Dev forums, but...well I can't find any info on it, and I'd like to know before I shell out to buy a mac for the iPhone SDK. Basically I am wondering if it is possible to run a console script (.sh) from an iPhone App. The script is written to download a program from a repository that I set up, respring, then after a set time delete the program and respring again, so it needs root privileges, and is interactive in that the user can set how long the program will be kept. I have the bash script written, and it works fine when called from mobile terminal, but is there any way to do this from within a (jailbroken) app (without using mobile terminal / SSH / Bossprefs)? Or is there an overall better way to achieve this?
Thanks
I don't have any solution for you, but I'm really interested by your script as I need to write exactly the same one, and I don't know how to write shell scripts. So.. i fyou could help me (or post your script here...) that would be marvelous for me!

Regards
Alx is offline   Reply With Quote
Old 06-30-2009, 08:19 AM   #3 (permalink)
New Member
 
Join Date: Jun 2009
Posts: 4
rocomotion is on a distinguished road
Default

hey, so the code for this is pretty simple....

Code:
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
#check for root privileges
if [ $UID -ne 0 ]; then
  echo Please, type root password...
  su -c $0 $@
  exit
fi
echo "WARNING: This Program will shutdown and delete Program when the allotted time has expired."
echo "Please be sure to save your work before then"
echo "How many minutes will you use this program?"
read response
#retrieve yourApp (insert desired app name) from repos
echo y | apt-get install com.<developer>.<yourApp>
#respring
launchctl stop com.apple.SpringBoard
sleep "$((response * 60))";
#removed app after allotted time
apt-get -y remove com.RCM.CitrixReciever
launchctl stop com.apple.SpringBoard
note that for now this must be run either with mobileTerminal or via ssh, as it is a console script. I've made a bit of headway with launching it from the springboard, I'll probably use fopen() to do it. I'll post back if I get it figured out. Let me know if you've got any questions about the script
rocomotion is offline   Reply With Quote
Old 06-30-2009, 08:29 AM   #4 (permalink)
Registered Member
 
mnemonic_fx's Avatar
 
Join Date: Jun 2008
Posts: 419
mnemonic_fx is an unknown quantity at this point
Default

If Cydia can do it, so can your app. But, you'll find better answers on other place, not on this forum.
__________________
Visit Me

Writing code is not only about writing instructions to a machine / computer, but also about writing something that could be read, understood, and maintained by others. That's why, I like Cocoa.
mnemonic_fx is offline   Reply With Quote
Old 06-30-2009, 10:15 AM   #5 (permalink)
Registered Member
 
Stitch's Avatar
 
Join Date: Aug 2008
Posts: 400
Stitch is on a distinguished road
Default

I agree with "mnemonic_fx" best not to discuss it here.

However, Cydia IS run as root and the source code is/was available on the internet.
Stitch is offline   Reply With Quote
Reply

Bookmarks

Tags
jailbreak, script, terminal

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 339
8 members and 331 guests
chiataytuday, givensur, ipodphone, jbro, mtl_tech_guy, Punkjumper, vilisei, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,881
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:14 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0