Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

21 May, 2024: Computers section is temporarily disabled for maintenance. It will take several days before it's back.


devel / comp.lang.tcl / Pipe-open program control on Windows

SubjectAuthor
* Pipe-open program control on WindowsDonald Arseneau
+* Re: Pipe-open program control on Windowset99
|`- Re: Pipe-open program control on WindowsDonald Arseneau
+- Re: Pipe-open program control on WindowsColin Macleod
`* Re: Pipe-open program control on WindowsRalf Fassel
 `* Re: Pipe-open program control on WindowsDonald Arseneau
  +* Re: Pipe-open program control on WindowsDonald Arseneau
  |`- Re: Pipe-open program control on Windowset99
  `- Re: Pipe-open program control on WindowsAndreas Leitgeb

1
Pipe-open program control on Windows

<yfiplu7sadv.fsf@triumf.ca>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=23916&group=comp.lang.tcl#23916

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: asnd@triumf.ca (Donald Arseneau)
Newsgroups: comp.lang.tcl
Subject: Pipe-open program control on Windows
Date: Mon, 29 Apr 2024 22:11:08 -0700
Organization: TRIUMF: Canada's national meson facility
Lines: 33
Message-ID: <yfiplu7sadv.fsf@triumf.ca>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Tue, 30 Apr 2024 07:11:08 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="17451177fef8c8961833a541769fc0fb";
logging-data="2403557"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cvAaVgP2uAIShmwYy5OdK"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock: sha1:t4fqhqDVDcG17sSylq3ANixBqsA=
sha1:0UftHnGQOL88beoxujQPbxi/X0g=
 by: Donald Arseneau - Tue, 30 Apr 2024 05:11 UTC

It is peaceful here without the spam.

I have a black-box textual program for controlling a device.
I thought I'd make some scriptable remote control, but when I tried
using pipe-open there is no communication.
Does this sound familiar to someone who uses Tcl on Windows more than
I do?

More specifics...

set pfh [open "C:/Users/$tcl_platform(user)/blah/foobar.exe" r+]
fconfigure $pfh -blocking 0 -translation binary

The task manager shows the "foobar" task running.
(The task manager shows it running even after [close $pfh].)

I used [read $pfh] or [read $pfh 1] but both returned no characters.
I sent input to it using puts -nonewline $pfh "\r"; flush $pfh
but no responses were seen by read.
Fileevent readable never triggers.

This program does seem to run in the cmd terminal when you type it's
path, but if you click on it in explorer, it opens a cmd terminal to run
in.

Does it sound that pipe-open is bound to fail?
Should I try expect (but I don't think expect exists for Windows now)?
Maybe twapi can interface, but I've never used twapi and don't know.

Thanks for any insight I can get from more experienced denizens.

--
Donald Arseneau asnd@triumf.ca

Re: Pipe-open program control on Windows

<v0q4k1$2ampq$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=23917&group=comp.lang.tcl#23917

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: Pipe-open program control on Windows
Date: Mon, 29 Apr 2024 23:54:57 -0700
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <v0q4k1$2ampq$1@dont-email.me>
References: <yfiplu7sadv.fsf@triumf.ca>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 30 Apr 2024 08:54:57 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="c828c4de8fa94bfb6e5d99897f50c047";
logging-data="2448186"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18IvMVwAKrdjdMnhQxNw4m9"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:NXnQUT7zLmI7rSinGSflkjawMf8=
In-Reply-To: <yfiplu7sadv.fsf@triumf.ca>
Content-Language: en-US
 by: et99 - Tue, 30 Apr 2024 06:54 UTC

On 4/29/2024 10:11 PM, Donald Arseneau wrote:

> More specifics...
>
> set pfh [open "C:/Users/$tcl_platform(user)/blah/foobar.exe" r+]
> fconfigure $pfh -blocking 0 -translation binary
>
Is that the actual code? Don't you need a pipe char | before the file name?

-e

Re: Pipe-open program control on Windows

<1714460349-7@cmacleod.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=23918&group=comp.lang.tcl#23918

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!cmacleod.me.uk!.POSTED!not-for-mail
From: user7@cmacleod.me.uk.invalid (Colin Macleod)
Newsgroups: comp.lang.tcl
Subject: Re: Pipe-open program control on Windows
References: <yfiplu7sadv.fsf@triumf.ca>
Date: Tue, 30 Apr 24 06:59:09 GMT
Message-ID: <1714460349-7@cmacleod.me.uk>
Injection-Info: cmacleod.me.uk; mail-complaints-to="newsgrouper@yahoo.com"; posting-account=user7
Injection-Date: Tue, 30 Apr 24 06:59:09 GMT
User-Agent: Newsgrouper/0.5
 by: Colin Macleod - Tue, 30 Apr 2024 06:59 UTC

Donald Arseneau <asnd@triumf.ca> posted:

> It is peaceful here without the spam.
>
> I have a black-box textual program for controlling a device.
> I thought I'd make some scriptable remote control, but when I tried
> using pipe-open there is no communication.
> Does this sound familiar to someone who uses Tcl on Windows more than
> I do?
>
I suspect TWAPI is your best bet, specifically the functions for sending
keyboard and mouse input - https://twapi.magicsplat.com/v4.7/input.html
My rather crude https://wiki.tcl-lang.org/page/AdvertSkipper+for+YouTube
uses this stuff.

If you need to read output from the controlled program, I would look at
sending the keystrokes to copy the output to the clipboard, and then use
the Tk clipboard command to read that.

--
Colin Macleod.

Re: Pipe-open program control on Windows

<ygah6fjrvpv.fsf@akutech.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=23920&group=comp.lang.tcl#23920

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: Pipe-open program control on Windows
Date: Tue, 30 Apr 2024 12:27:56 +0200
Lines: 36
Message-ID: <ygah6fjrvpv.fsf@akutech.de>
References: <yfiplu7sadv.fsf@triumf.ca>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net FKHf+dxQP8o7vBgQoJ5z6gvKUBRKRV9KoN5753X/kdmvRDWDY=
Cancel-Lock: sha1:77Dhzd0A5+AXfuc8onHCYQcFCII= sha1:gCIg7AC2kY9nUfSzkNFE0ew+7PI= sha256:aIDh7OnBqDNkPDhv6cpADigMu01f7r1potTCygQkoKc=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Tue, 30 Apr 2024 10:27 UTC

* Donald Arseneau <asnd@triumf.ca>
| It is peaceful here without the spam.

:-)

| More specifics...
>
| set pfh [open "C:/Users/$tcl_platform(user)/blah/foobar.exe" r+]

et99 already pointed out the missing "|" at the start of the command,
but since you say the task is running, I assume this is just a
copy/paste error.

| I used [read $pfh] or [read $pfh 1] but both returned no characters.
| I sent input to it using puts -nonewline $pfh "\r"; flush $pfh
| but no responses were seen by read.
| Fileevent readable never triggers.

It all depends whether the foobar.exe actually uses stdin/stdout for
communication, and whether it flushes its stdout when it writes
something. Does the program generate output when it start which you can
redirect to a file? I.e. running

foobar > _tmp.txt

in a cmd shell, does that create contents in that file?

| Does it sound that pipe-open is bound to fail?

In general: no. I use pipe-open on Windows on a regular basis, though
mostly between my own (TCL-based-)programs, which set stdout to line
buffering, so each 'puts' actually flushes the output, so the other
process can read it.

HTH
R'

Re: Pipe-open program control on Windows

<yfibk5qwq2d.fsf@triumf.ca>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=23923&group=comp.lang.tcl#23923

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: asnd@triumf.ca (Donald Arseneau)
Newsgroups: comp.lang.tcl
Subject: Re: Pipe-open program control on Windows
Date: Tue, 30 Apr 2024 13:31:06 -0700
Organization: TRIUMF: Canada's national meson facility
Lines: 18
Message-ID: <yfibk5qwq2d.fsf@triumf.ca>
References: <yfiplu7sadv.fsf@triumf.ca> <v0q4k1$2ampq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Tue, 30 Apr 2024 22:31:07 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="17451177fef8c8961833a541769fc0fb";
logging-data="2817173"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YNhIDqgz9xz7KWdtuEazg"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock: sha1:pltoxxK2VNAAwIClgTRmFx8xjLk=
sha1:9H2DXFEZdxWKAsQhlcZsNig+/Og=
 by: Donald Arseneau - Tue, 30 Apr 2024 20:31 UTC

et99 <et99@rocketship1.me> writes:

> On 4/29/2024 10:11 PM, Donald Arseneau wrote:
>
>> More specifics...
>>
>> set pfh [open "C:/Users/$tcl_platform(user)/blah/foobar.exe" r+]
>> fconfigure $pfh -blocking 0 -translation binary
>>
> Is that the actual code? Don't you need a pipe char | before the file name?

ACK! Typo In the message, but not in the test.

So clumsy.

--
Donald Arseneau asnd@triumf.ca

Re: Pipe-open program control on Windows

<yfile4u34gw.fsf@triumf.ca>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=23924&group=comp.lang.tcl#23924

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: asnd@triumf.ca (Donald Arseneau)
Newsgroups: comp.lang.tcl
Subject: Re: Pipe-open program control on Windows
Date: Tue, 30 Apr 2024 14:50:23 -0700
Organization: TRIUMF: Canada's national meson facility
Lines: 40
Message-ID: <yfile4u34gw.fsf@triumf.ca>
References: <yfiplu7sadv.fsf@triumf.ca> <ygah6fjrvpv.fsf@akutech.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Tue, 30 Apr 2024 23:50:24 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="17451177fef8c8961833a541769fc0fb";
logging-data="2851609"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ojPuvaB2tWif2qIvCSOPy"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock: sha1:FyUUtnOwWbdqYF76gCPyMBY0K1o=
sha1:kasrmKni8JmRHx/0ImlNJmFK//A=
 by: Donald Arseneau - Tue, 30 Apr 2024 21:50 UTC

Ralf Fassel <ralfixx@gmx.de> writes:

> | set pfh [open "C:/Users/$tcl_platform(user)/blah/foobar.exe" r+]
>
> et99 already pointed out the missing "|" at the start of the command,
> but since you say the task is running, I assume this is just a
> copy/paste error.

I typed it in the message without pasting (not blah/foobar).

> | I used [read $pfh] or [read $pfh 1] but both returned no characters.
> | I sent input to it using puts -nonewline $pfh "\r"; flush $pfh
> | but no responses were seen by read.
> | Fileevent readable never triggers.
>
> It all depends whether the foobar.exe actually uses stdin/stdout for
> communication, and whether it flushes its stdout when it writes
> something. Does the program generate output when it start which you can
> redirect to a file? I.e. running
>
> foobar > _tmp.txt
>
> in a cmd shell, does that create contents in that file?

Great test! Yes it does populate the file, including the echoed
input commands and the output. The output file is created immediately,
but does not get any text until the program exits (which I did by typing
q<CR>).
>
> | Does it sound that pipe-open is bound to fail?
>
> In general: no. I use pipe-open on Windows on a regular basis, though
> mostly between my own (TCL-based-)programs, which set stdout to line
> buffering, so each 'puts' actually flushes the output, so the other
> process can read it.

I wonder if I can start that program in a way that defeats buffering...

--
Donald Arseneau asnd@triumf.ca

Re: Pipe-open program control on Windows

<yfi1q6mpkky.fsf@triumf.ca>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=23925&group=comp.lang.tcl#23925

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: asnd@triumf.ca (Donald Arseneau)
Newsgroups: comp.lang.tcl
Subject: Re: Pipe-open program control on Windows
Date: Tue, 30 Apr 2024 15:11:25 -0700
Organization: TRIUMF: Canada's national meson facility
Lines: 12
Message-ID: <yfi1q6mpkky.fsf@triumf.ca>
References: <yfiplu7sadv.fsf@triumf.ca> <ygah6fjrvpv.fsf@akutech.de>
<yfile4u34gw.fsf@triumf.ca>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Wed, 01 May 2024 00:11:25 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="a1471170d8977aa4cc61327655aefcf5";
logging-data="2863768"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18w8bBXAx3fDevAAf9FXbNO"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock: sha1:reWpkbdyMbWM2I/qB8fVhLkkz4I=
sha1:xO6QsZjqfonL17Q7DGU9P+isplk=
 by: Donald Arseneau - Tue, 30 Apr 2024 22:11 UTC

Donald Arseneau <asnd@triumf.ca> writes:

> I wonder if I can start that program in a way that defeats buffering...

I should add that I tried
fconfigure $pfh -blocking 0 -buffering none -translation binary
and lots of
flush $pfh
already.

--
Donald Arseneau asnd@triumf.ca

Re: Pipe-open program control on Windows

<v0s1jc$2p1q4$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=23926&group=comp.lang.tcl#23926

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: Pipe-open program control on Windows
Date: Tue, 30 Apr 2024 17:15:39 -0700
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <v0s1jc$2p1q4$1@dont-email.me>
References: <yfiplu7sadv.fsf@triumf.ca> <ygah6fjrvpv.fsf@akutech.de>
<yfile4u34gw.fsf@triumf.ca> <yfi1q6mpkky.fsf@triumf.ca>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 01 May 2024 02:15:41 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="0b0aa5402519e9db8c153c867d6effd2";
logging-data="2918212"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+utvtBbGtwWnwNCgjo3i6f"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:diIgNtPe/91PONsFIhhwtWZslRQ=
Content-Language: en-US
In-Reply-To: <yfi1q6mpkky.fsf@triumf.ca>
 by: et99 - Wed, 1 May 2024 00:15 UTC

On 4/30/2024 3:11 PM, Donald Arseneau wrote:
> Donald Arseneau <asnd@triumf.ca> writes:
>
>> I wonder if I can start that program in a way that defeats buffering...
>
> I should add that I tried
> fconfigure $pfh -blocking 0 -buffering none -translation binary
> and lots of
> flush $pfh
> already.
>

Since you have a "black-box" executable, what about redirecting both it's input/output and then use named pipes for both, to see what's going on.

I got chatGPT to write some code in C, python, and Tcl for creating and then reading/writing to named pipes.

From a command line you can then do: foobar.exe < \\.\pipe\MyNamedPipe

to see if foobar.exe will cooperate on reading from a pipe. You can also then send it stuff, and multiple readers will each see all the data (like tee), or so chatGPT tells me.

FWIW, chatGPT seemed pretty knowledgeable about named pipes and wrote some decent Tcl code :)

Here's what it gave me as a test program to write to the pipe:

proc write_to_named_pipe {pipe_tail data} {
set pipeName "\\\\.\\pipe\\$pipe_tail"
set pipe [open $pipeName w]
puts $pipe $data
close $pipe
}

# Check if two command-line arguments are provided
if {[llength $argv] == 2} {
# Get the command-line arguments
set data [lindex $argv 0]
set pipeTail [lindex $argv 1]

# Write the data to the named pipe
write_to_named_pipe $pipeTail $data
} else {
puts "Usage: tclsh script_name.tcl data pipe_tail"
}


-e

Re: Pipe-open program control on Windows

<slrnv3533u.23q10.avl@logic.at>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=23928&group=comp.lang.tcl#23928

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: avl@logic.at (Andreas Leitgeb)
Newsgroups: comp.lang.tcl
Subject: Re: Pipe-open program control on Windows
Date: Wed, 1 May 2024 18:39:58 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <slrnv3533u.23q10.avl@logic.at>
References: <yfiplu7sadv.fsf@triumf.ca> <ygah6fjrvpv.fsf@akutech.de>
<yfile4u34gw.fsf@triumf.ca>
Reply-To: avl@logic.at
Injection-Date: Wed, 01 May 2024 20:39:58 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="d66944045fcbe33875d95881d11581bd";
logging-data="3478003"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cIRKOXys9lN/FEYuZqFR5"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:95s0Bj4VQV8FjaNx3hKAnJCBVoM=
 by: Andreas Leitgeb - Wed, 1 May 2024 18:39 UTC

Donald Arseneau <asnd@triumf.ca> wrote:
> Ralf Fassel <ralfixx@gmx.de> writes:
>> It all depends whether the foobar.exe actually uses stdin/stdout for
>> communication, and whether it flushes its stdout when it writes
>> something. Does the program generate output when it start which you can
>> redirect to a file? I.e. running
>> foobar > _tmp.txt
>> in a cmd shell, does that create contents in that file?
>
> Great test! Yes it does populate the file, including the echoed
> input commands and the output. The output file is created immediately,
> but does not get any text until the program exits (which I did by typing
> q<CR>).
>
> I wonder if I can start that program in a way that defeats buffering...

I think, that is just the gap for "expect", and I think such exists, or
at least once existed for Windows. Maybe some aged "expect 4 windows"
found on the 'net might be enough for this task, if it is based on some
8.3, 8.4 or 8.5 tcl...


devel / comp.lang.tcl / Pipe-open program control on Windows

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor