Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

lawlist

macrumors member
Original poster
In order to connect the iphone via ssh over usb on the mac, it is necessary to run a terminal command. Can anyone please help me figure out how to have a simple command string run in the terminal every time I startup, and have the terminal window close automatically when it is done? I have lingon, which should make it easy, but I still need help. I created a "user agent", but it doesn't seem to be doing the trick and there are no error messages. Here is the string I need to run from terminal every time the computer starts up (and then close the terminal after the string is run):

python /Applications/python-client/tcprelay.py -t 22:2222 &

Or get to the directory /Applications/python-client, and then run

python tcprelay.py -t 22:2222 &

Thanks.
 

Attachments

  • lingon.png
    lingon.png
    89.1 KB · Views: 351
I wrote a simple shell script with 755 permissions and used lingon to execute the shell script with a user agent -- command string "sh [absolute path to shell script]".

#!/bin/bash

# iphone usb ssh script

/Applications/python-client/tcprelay.py -t 22:2222 &

However, I was unable to figure out how to force the full command string to execute without a shell script just by running a user agent at logon -- the farthest I got was executing tcprelay.py without the arguments, and am not sure why the arguments are not recognized -- looking in /var/log/system.log revealed that tcprelay.py was being executed without arguments despite the user agent seemingly containing the correct arguments.
 
If I am reading this correctly you could just go to Preferences in Terminal (⌘ + ,) Settings > Shell: Startup then ✓ the 'Run command:' box and type in what you think is the best solution.

You could type: cd /Applications/python-client; python tcprelay.py -t 22:2222 &

While in Settings > Shell: When the shell exits: and select the Close the window option.

Regarding Lingon I haven't personally used it… One question why did you want to ssh via USB? 🙄
 

Attachments

  • Screen Grab 2011-01-22 at 9.07.33 PM.png
    Screen Grab 2011-01-22 at 9.07.33 PM.png
    81.7 KB · Views: 164
Thank you -- I just tried your method and that is indeed a viable alternative. After contacting the Lingon developer a few weeks back, who told me that he also uses shell scripts for more complicated jobs, I chose to use "Platypus-4.4" to create an app with a built-in shell script, and I used the OSX login system preferences to select the app I created -- the script was just two lines:

#!/bin/sh

/usr/bin/python2.6 /Applications/python-client/tcprelay.py -t 22:2222 &

The reason for this project is that I have a jailbroken iPhone with iOS 4.1, and I synchronize my 10GB master database by transferring files to / from the iOS device using a usb connection to the Mac, instead of wireless. The result is that I can transfer multiple files and/or very large files at maximum data transfer speeds. With this setup, I just hook up the iPhone to the Mac with the usb cable and it is ready for usb data transfer using ForkLift2. I did this on the desktop, and on the two laptops.

https://github.com/gilir/usbmuxd-debian/tree/debian/python-client/
 
Ahh, That is a hefty file for ssh via wireless I see why you use the ForkLift2 method!!
Also, that solution made me recall Apple Script Editor which is perfect for something i was working on. I should be thanking you! xD
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.