Results 1 to 15 of 15

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: how do i run a script in terminal.

  1. #1
    iPhone? More like MyPhone JustinPizzle's Avatar
    Join Date
    Aug 2008
    Location
    California
    Posts
    212
    Thanks
    13
    Thanked 16 Times in 16 Posts

    Default how do i run a script in terminal.
    how can i execute scrips to be run in terminal. (on the iphone)

    im using the sendsms code line, and im having this competition with a buddy of mine
    irrelevent sorry.

    i need
    sendsms 55555555 "hey"
    to run, then wait for it to send and succeed in sending the message, and then run the script again.
    preferably stop at around 20 or 30.

    so i dont get stuck in a loop.

    anyone know how i can do this?
    any help is appreciated


    btw wer having a competition as to who can send the most texts in half an hour
    and at no time did anyone say anything about automated sending

  2. #2
    My iPhone is a Part of Me
    Join Date
    Oct 2007
    Location
    Colorado
    Posts
    569
    Thanks
    10
    Thanked 53 Times in 41 Posts

    Your title question is not the same as the question in your message. So I will only answer the title quesion:
    chmod 755 program
    ./program

  3. #3
    iPhone? More like MyPhone JustinPizzle's Avatar
    Join Date
    Aug 2008
    Location
    California
    Posts
    212
    Thanks
    13
    Thanked 16 Times in 16 Posts

    Well that's almost no help...

  4. #4
    Livin the iPhone Life
    Join Date
    Aug 2008
    Location
    New York
    Posts
    1,023
    Thanks
    3
    Thanked 78 Times in 63 Posts

    Since the iPhone uses the Bourne Again SHell just look the command in a .sh script. Chmod it to +x and run ./script.sh
    #!/bin/bash

    i="0"

    while [ -lt 20 ]
    do
    sendsms 55555555 "hey" &
    i=$[+1]
    done

  5. The Following User Says Thank You to boxxa For This Useful Post:

    JustinPizzle (08-06-2009)

  6. #5
    iPhone? More like MyPhone JustinPizzle's Avatar
    Join Date
    Aug 2008
    Location
    California
    Posts
    212
    Thanks
    13
    Thanked 16 Times in 16 Posts

    Ok so I make
    a spript file named whatever.sh
    containing what you quoted
    and then just put it on the phone and run it with terminal?

    I'm on the iPhone. Sorry about the spelling****
    Last edited by JustinPizzle; 08-06-2009 at 03:24 PM. Reason: Automerged Doublepost
    If i helped you, clicking thanks would be nice

  7. #6
    Livin the iPhone Life
    Join Date
    Aug 2008
    Location
    New York
    Posts
    1,023
    Thanks
    3
    Thanked 78 Times in 63 Posts

    Quote Originally Posted by JustinPizzle View Post
    Ok so I make
    a spript file named whatever.sh
    containing what you quoted
    and then just put it on the phone and run it with terminal?

    I'm on the iPhone. Sorry about the spelling****
    Ya not able to test it on a phone but upload a text file named sms_test.sh or whatever with that in there and then go into your terminal and type:

    chmoh +x sms_test.sh

    After that, try to run it: ./sms_test.sh

    No idea if it will work. In theory tho it should.

  8. #7
    iPhone? More like MyPhone JustinPizzle's Avatar
    Join Date
    Aug 2008
    Location
    California
    Posts
    212
    Thanks
    13
    Thanked 16 Times in 16 Posts

    haha im going to try it right now.
    THANKS!

    ok well the .sh file runs. but nothing happens.
    it just returns like it was successful and then theres nothing...

    and yes, i did replace the 55555555 number with my own.
    Last edited by JustinPizzle; 08-06-2009 at 09:34 PM. Reason: Automerged Doublepost
    If i helped you, clicking thanks would be nice

  9. #8
    Livin the iPhone Life
    Join Date
    Aug 2008
    Location
    New York
    Posts
    1,023
    Thanks
    3
    Thanked 78 Times in 63 Posts

    Take out the & after the sendsms command and see what the output is. Do u have the sendsms package installed from cydia?

  10. #9
    iPhone? More like MyPhone JustinPizzle's Avatar
    Join Date
    Aug 2008
    Location
    California
    Posts
    212
    Thanks
    13
    Thanked 16 Times in 16 Posts

    how should i go about making the .sh file.

    ive tried with text edit and apple scrip editor

    and removing the & still is a no go
    If i helped you, clicking thanks would be nice

  11. #10
    Livin the iPhone Life
    Join Date
    Aug 2008
    Location
    New York
    Posts
    1,023
    Thanks
    3
    Thanked 78 Times in 63 Posts

    Use vi or make it on your computer and upload it to the phone. Its just a text file.


    if you run sendsms "5555555555" "Test" from the terminal does it work? Make sure you get sendsms working properly before you worry about the script.

  12. #11
    iPhone? More like MyPhone JustinPizzle's Avatar
    Join Date
    Aug 2008
    Location
    California
    Posts
    212
    Thanks
    13
    Thanked 16 Times in 16 Posts

    yup. it works fine without the script.

    i make it with text edit. save as "sh.rtf"
    then remove the "rtf"
    and upload it onto the phone.
    then all the commands you said, down to the letter
    it runs, no errors but no sms is sent
    If i helped you, clicking thanks would be nice

  13. #12
    Well I am a Java programmer not a scriptor but you can solve the problem in a similar fashion. First thing I would do is eliminate the possibility of it being a communication problem with sms and instead of the sms command put in 'echo blah blah' and see if blah blah prints. If not then you know you arent ever going in the loop.

    Secondly why do you need to wait for it to finish sending before you try sending again anyway? I mean realistically you could make it an infinite loop that is stopped by some command. That is clearly not the 'best practices' approach however you are trying to win a bet not a nobel prize lol. My guess is that by sending them continuously one after another with no delay sms will error out whatever it cant process but it wont matter because while it is giving you error messages it is still processing the script. One thing I would test before doing something that crazy though is put a 1 sec delay in between them and see if accepts them. I dont know how it works but perhaps the app will queue what you are trying to send and if that is the case you will most likely overflow your buffer and crash your phone altogether if you have no delay and continuously do it for 20-30 minutes. So I would test like 10 seconds with 1 sec delays in between and see if you get 3 messages or 10.

  14. #13
    Livin the iPhone Life
    Join Date
    Aug 2008
    Location
    New York
    Posts
    1,023
    Thanks
    3
    Thanked 78 Times in 63 Posts

    Ya its probably flooding the SMS command and dropping it.

    Try this version:

    #!/bin/bash
    COUNTER=0
    while [ -lt 10 ]; do
    sendsms 5555555555 "hey"
    sleep 6
    let COUNTER=COUNTER+1
    done
    it will run the script and wait 6 seconds between loops and go through it 10 times so it will send out 10 messages in 1 minute.

  15. #14
    again I am no scriptor but I thought Id point out in the first script there is no semi colon after the while statement where as in the second one there is. Perhaps the first script was not executing because of a syntax error? Also the keyword let is missing from the first script. Again I dont know for sure but I am just comparing the 2 different scripts.

  16. #15
    Livin the iPhone Life
    Join Date
    Aug 2008
    Location
    New York
    Posts
    1,023
    Thanks
    3
    Thanked 78 Times in 63 Posts

    I typed both of those from memory. Here is a working script that I tested on a linux box. THe only difference between this one and the one I tested was that I just echoed a command instead of running sendsms since my server doesnt have a sendsms command.


    #!/bin/bash
    COUNTER=0
    while [ -lt 10 ]; do
    sendsms "5555555555" "hey"
    sleep 5
    let COUNTER=COUNTER+1
    done

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