[mdlug] Execute a command on a host after ssh

Jonathan Billings billings at negate.org
Sat Aug 11 15:20:33 EDT 2012


On Aug 11, 2012, at 2:44 PM, R KANNAN wrote:
> I want to execute a command (more precisely change to a directory) after
> sshing into a machine. The directory location is dynamic and is to be
> passed from a script. I could not find any way of doing this from the man
> pages for 'ssh'.

There's nothing specific to ssh for this, it sounds like just some shell scripting.

Why don't you just run something like this:

#!/bin/bash
mydir=/path/to/execute
mycommand=foo

ssh user at host "cd $mydir; $mycommand"

--
Jonathan Billings <billings at negate.org>





More information about the mdlug mailing list