OpenSSH
[Top] [All Lists]

Re: bending openssh output

To: marner <d.marner@mikro-software.de>
Subject: Re: bending openssh output
From: bob@proulx.com (Bob Proulx)
Date: Sat, 3 Mar 2007 10:46:07 -0700
Cc: openssh-unix-dev@mindrot.org
Delivered-to: sp-com-lists@consult.net
Delivered-to: openssh-unix-dev-list1@securepoint.com
Delivered-to: openssh-unix-dev-tmda@mindrot.org
Delivered-to: openssh-unix-dev@mindrot.org
In-reply-to: <1172827048.7069.22.camel@localhost>
List-archive: <http://lists.mindrot.org/pipermail/openssh-unix-dev>
List-help: <mailto:openssh-unix-dev-request@mindrot.org?subject=help>
List-id: Development of portable OpenSSH <openssh-unix-dev.mindrot.org>
List-post: <mailto:openssh-unix-dev@mindrot.org>
List-subscribe: <http://lists.mindrot.org/mailman/listinfo/openssh-unix-dev>, <mailto:openssh-unix-dev-request@mindrot.org?subject=subscribe>
List-unsubscribe: <http://lists.mindrot.org/mailman/listinfo/openssh-unix-dev>, <mailto:openssh-unix-dev-request@mindrot.org?subject=unsubscribe>
Mail-followup-to: marner <d.marner@mikro-software.de>, openssh-unix-dev@mindrot.org
References: <1172827048.7069.22.camel@localhost>
Sender: openssh-unix-dev-bounces+openssh-unix-dev-list1=securepoint.com@mindrot.org
User-agent: Mutt/1.5.9i
marner wrote:
> When I use openssh to build up a connection to a ssh server like this:
> ssh -myparameter pass user@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@host "ls -al * | grep .txt")
  
Then you can modify the output of ssh as a string and print it or
not.

Bob
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
http://lists.mindrot.org/mailman/listinfo/openssh-unix-dev

<Prev in Thread] Current Thread [Next in Thread>