bending openssh output

Bob Proulx bob at proulx.com
Sun Mar 4 04:46:07 EST 2007


marner wrote:
> When I use openssh to build up a connection to a ssh server like this:
> ssh -myparameter pass user at host "ls -al * | grep .txt"
> 
> I usually get a single line returned like 
> -rw-r--r--  1 user group 1223 2007-01-01 08:00 mydata.txt
> 
> Now my question:
> Where in the openssh source can I redirect the output of this line from
> stdout to a string variable I use? (so I could modify/parse it before
> writing it to stdout)

In shell you can grab the output of commands put put them into a
string using the old backtick `...` style or the newer $(...) style.
I suggest the newer style because the quoting rules are easier to
understand.

  var=$(ssh -myparameter pass user at host "ls -al * | grep .txt")
  
Then you can modify the output of ssh as a string and print it or
not.

Bob


More information about the openssh-unix-dev mailing list