[PD] executing commands from pd via pdreceive

Roman Haefeli reduzent at gmail.com
Sat Sep 11 10:43:21 CEST 2021


On Mon, 2021-09-06 at 21:51 +0200, Peter P. wrote:
> 
> 
> Is there a way I can let pd know that the command
> has finished executing? 
> For example by sending something back like
> 	pdreceive 8888 udp | sh - ; echo "done" | pdsend 8889 localhost
> udp
> which sadly does not work?

pdreceive won't exit, no matter if espeak is done or not. Slightly
modifying your attempt to send it to the background solves the report
back problem for me:

[send espeak "blah blah blah" && echo done | pdsend 9999 localhost udp(
|
[netsend -u]

[netreceive -u 9999]

works with this command:

	pdreceive 8888 udp | sh 
> 
> I would also like to spawn multiple espeak commands
> in parallel from one [netsend] using this approach but can't seem to
> make it work. Again using the command
> 	pdreceive 8888 udp | sh 
> and including an ampersand at the end of the Pd message like
> 	send espeak -p 20 "blah blah blah" &
> throws a
> 	sh: 1: Syntax error: ";" unexpected
> error on the shell terminal with pdreceive exiting.

I don't know how to do this with only one [netsend]/pdreceive pair. If
you can use many pairs, you can use above approach to detect when an
individual instance is done for reuse. 
> 
> Does anyone have an idea what I can try here (except for writing a
> wrapper script)?
> 
> Thank you for all ideas!

I wish doing such things would be easier in Pd. pdsend and pdreceive
give you some flexibility, but require that you actively initiate the
command first. 

I was hoping I could improve the situation with the [command]¹
external, but fail miserably. 'exec espeak hello my name is roman'
plays only 'hello'. When I use a symbol box to write the text, the
backslash escapes for the whitespaces are passed to espeak and the
result is 'hello backslash my backslash is [...]'. At least, it reports
correctly when the command has finished. If the external could be made
work correctly, it would be easier to run many instances of your idea
and also you wouldn't need any interaction outside of Pd, but
unfortunately we're not there yet.

Roman


¹https://github.com/pd-externals/command

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20210911/09bbf034/attachment.sig>


More information about the Pd-list mailing list