Terminal Script

Discussion in 'iOS Jailbreak & Cydia' started by Happyman7, Mar 14, 2010.

  1. Happyman7

    Happyman7 Member

    Joined:
    Sep 2, 2009
    Messages:
    679
    Likes Received:
    7
    Device:
    4G iPod touch
    I was wondering how I could make and run a script in Mobile Terminal.

    Example:
  2. Sul

    Sul New Member

    Joined:
    Mar 8, 2009
    Messages:
    17
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    name:

    Code:
    examplescript
    Code:
    #!/bin/bash
    #Sull's Example Script
    
    #Remove File
    rm /System/Library/Example.plist
    
    #Remove Directory
    rmdir /System/Library/ExampleDirectrory
    
    #Or Perhaps you want to check a folder or file exists
    
      if [ -f /System/Library/Example.plist ]; then
        mv /System/Library/Example.plist /System/Library/Example.plist.bkup
        echo "Example.plist backed up"
      else
       echo "Different Example message. run a different command here...
      fi
    #end script
    You need to know some unix commands

    Please Register or Log in to view images

  3. Shawa

    Shawa Super Moderator

    Joined:
    Jan 31, 2009
    Messages:
    3,188
    Likes Received:
    22
    Device:
    Nexus 4
    An image cache clean would make an excellent SBSettings button.
  4. Happyman7

    Happyman7 Member

    Joined:
    Sep 2, 2009
    Messages:
    679
    Likes Received:
    7
    Device:
    4G iPod touch
    Sul: Thanks

    Please Register or Log in to view images

    I know Unix from the brief period of when I was using Ubuntu (a Linux distro). But how would I start the script(s)?


    Shåwa: That is quite off topic, but yes it would be a good idea. Although it would take up some SBSettings button space...
  5. Sul

    Sul New Member

    Joined:
    Mar 8, 2009
    Messages:
    17
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    in MobileTerminal go root

    Code:
    su
    type your password

    Code:
    ./examplescript
  6. Happyman7

    Happyman7 Member

    Joined:
    Sep 2, 2009
    Messages:
    679
    Likes Received:
    7
    Device:
    4G iPod touch
    So it is just
  7. Sul

    Sul New Member

    Joined:
    Mar 8, 2009
    Messages:
    17
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    Yeah try that. Make a test script and try it.

    Code:
    #!/bin/bash
    
    echo "Testing script"
    
    #end script
    
    
    put that in a script and try to run it!
    ------------------double post merged------------------
    You need to set the permissions to probably at least 755, but I would just give it full permissions 777

    Code:
    chmod 777 scriptname
  8. Happyman7

    Happyman7 Member

    Joined:
    Sep 2, 2009
    Messages:
    679
    Likes Received:
    7
    Device:
    4G iPod touch
    OK, Thank you very much. Stay tuned in case of any more questions.
  9. Sul

    Sul New Member

    Joined:
    Mar 8, 2009
    Messages:
    17
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    No worries!

    You can hit me up at [PIRACY]ph0ne we can chat in the shoutbox! I know a little bit about iDevice and scripts

    Please Register or Log in to view images

  10. Happyman7

    Happyman7 Member

    Joined:
    Sep 2, 2009
    Messages:
    679
    Likes Received:
    7
    Device:
    4G iPod touch
    Ok, I got my hands into the code (it's been a while).

    I am having trouble with the sleep command in a script of mine.
    I am doing this:
    Code:
    sleep 30s
    which is to make it sleep/pause for 30 seconds, but it is not working. What it the proper syntax of the sleep command, the terminal tells me how, but I don't understand it.

    Also, I am getting the "Unexpected end of file warning," how would I end the file.

Share This Page