Automate mobile terminal? I have a jailbroken iPhone.
I use it to reboot my router when my wifi is going slow or messing up.
But I'm lazy and I was looking for a way to automate the process.
I use shortcuts that mobile terminal lets you create so you can just tap the command instead of having to type it.
But is there a way I can create a script or run everything with a single command to do this for me?

Commands are as follows:

su

(su password)

ssh 192.168.1.1

(router password)

reboot


Can I jam all of that into one single process?
The script you want would be the following:

#!/bin/bash
su
ssh 192.168.1.1 &lt;&lt;-EOF
    reboot
    exit
EOF


If you can ssh into your iPhone from a computer, do so. Once you're logged in, create a new text file using nano ~/script (install nano from cydia if it isn't already) and paste the above script. Then hit ^X (control-X) and Y to save the script. The script is in your home directory (~) for quick access. Now, set the proper permissions to be able to execute the script: 

chmod 755 script


Now you can open MobileTerminal on the iPhone and type ./script, which will execute it.

If you have to do it locally, the easiest way is probably using iFile: open it and change to the home folder using the button at the bottom of the screen.


Tap on "edit" (top right) and "+" (bottom left). 
Enter a name and change the type to "Regular File", then tap "Create". 
Tap on the file and select "Text Viewer" in the list. 
Tap on "Edit" and copy the above script
Tap "Save" and "Done" and go to MobileTerminal to execute it (no need to set permissions, iFile did it)


Final note: you might want to set up automatic login using keys: http://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/

That way, you only have to launch the script, no password-typing required.