[mdlug] Execute a command on a host after ssh
R KANNAN
rk111810 at gmail.com
Sat Aug 11 16:17:03 EDT 2012
I want an interactive session after executing 'cd'. So Michael Moi's
suggestion seems to be a good suggestion to try. Thanks
On Sat, Aug 11, 2012 at 3:20 PM, Jonathan Billings <billings at negate.org>wrote:
> 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>
>
>
> _______________________________________________
> mdlug mailing list
> mdlug at mdlug.org
> http://mdlug.org/mailman/listinfo/mdlug
>
More information about the mdlug
mailing list