[Gambas-user] OUTPUT TO, stdout and command line usage
adamnt42 at gmail.com
Wed Aug 25 20:31:43 CEST 2021
On Wed, 2021-08-25 at 10:17 -0400, T Lee Davidson wrote:
> Perhaps something like this might do what you need:
> Public Sub Form_Open()
> Dim sOutput As String
> Shell Subst("lsof -p &1 -a -d 1 | grep REG", Application.Id) To
> If sOutput Then 'someone's trying to be sneaky
> TextArea1.Text = Split(sOutput, " ").Last
> Using "-d 1" assumes that any program output redirection will be
> given the second available file descriptor (zero-indexed). I'm
> not sure that would always be the case, and so "-d 0-3" might be more
> appropriate. But, then you'd need to process each line
> individually to find the one opened with the write attribute (eg.
I'm using Subst("lsof -p &1 -a -d 1", Application.Id) i.e. without the
grep as that would miss redirects to /dev/null.
-d 1 must work, at least for bash, otherwise "xyzzy > blah.txt &2>&1"
More information about the User