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

iBroken

macrumors newbie
Original poster
Jul 17, 2011
27
0
Hi

i've a script that i'm using a lot to connect to my server its simple, i've server with setting no-password SSH, so its like this

PHP:
tell application "Terminal"
	do script "ssh user@host"
end tell

i want to make a command as soon as my Mac connect to the server, if i write new "do script" line, it will be performed locally on my Mac in other terminal window, so what to do to make my server do this command after the ssh connect ?
 
Last edited:
You wouldn't do ssh to run a command on the remote host, you would use rsh (remote shell).

Go into terminal and do "man rsh"

Just remember that you get a bare shell and bare PATH variables when you do an rsh. You need to setup the login/profile/whatever else you need to setup the environment in order to run your command.

Typically, you would create a shell script that contains all setup and runs the command your looking to run.

If your just doing things like cp or mv, etc..., you can just call it with the full path
ie.
rsh -l user remotehost /bin/cp /home/myname/myfile /destination

Since your using no password, I assume you have the trust setup already auth.conf??? I forget which file you set on the remote.

I had some code laying around, but I can't locate just now, otherwise I'd post a real example.
 
To run "script" on a remote computer, just use:
ssh user@host ./script

This assumes script is in your home directory and is executable. Otherwise you'd type:
ssh user@host sh ./script

For example, to make sure the ssh command is being run where you want it to be, just type:
ssh user@host hostname

You can setup ssh agents and keys if you want to be able to login without typing passwords.

ssh is the secure remote shell replacement for rsh. It's quite possible rsh doesn't work, many systems have this turned off now.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.