Re: [PD] Control external command from Pd
On Thu, 2016-12-01 at 14:01 +0100, Jack wrote: > OK, i see now. > > For me, the best option is to do a bash script "myscript.bash" : > > while read line > do > echo "$line" > done < <(ping netpd.org & echo $!) > > > Then with pd : > > [bash myscript.bash( > > > > > [shell] > > You should be able to terminate the process with the pid return by > echo $! You made my day. That's exactly what I was looking for. Thanks! Roman signature.asc Description: This is a digitally signed message part ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Re: [PD] Control external command from Pd
OK, i see now. For me, the best option is to do a bash script "myscript.bash" : while read line do echo "$line" done < <(ping netpd.org & echo $!) Then with pd : [bash myscript.bash( | [shell] You should be able to terminate the process with the pid return by echo $! ++ Jack Le 01/12/2016 à 11:52, Roman Haefeli a écrit : > On Thu, 2016-12-01 at 11:37 +0100, Jack wrote: >> Le 01/12/2016 à 11:30, Roman Haefeli a écrit : >>> >>> On Thu, 2016-12-01 at 11:09 +0100, Jack wrote: Hello Roman, Did you try : [command & echo $!( > > > [shell] It will return the pid of 'command'. >>> Yes, you're right: It's not even necessary to put that into an >>> extra >>> script (I thought I had to because of the dollar sign). >>> >>> However, the problem remains: When I send 'command' to background, >>> [shell] won't output its stdout to the left outlet anymore. >> Hmm, weird, did you get something with ? : >> (start Pd from a directory where there are files and directories). >> >> [ls & echo $!( >>> >>> >> [shell] > > Yes, that works for me, too. But it's not a good example, since ls is a > one shot command and exits immediately. > > Try this: > > [ping netpd.org & echo $!( > > The actual command I'm interested to work with is 'jacktrip'. > > Roman > > > > ___ > Pd-list@lists.iem.at mailing list > UNSUBSCRIBE and account-management -> > https://lists.puredata.info/listinfo/pd-list > signature.asc Description: OpenPGP digital signature ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Re: [PD] Control external command from Pd
On Thu, 2016-12-01 at 11:29 +0100, Peter P. wrote: > * Roman Haefeli[2016-12-01 10:52]: > > > > Hey all > > > > I would like to use Pd to start and stop several instances of a > > certain > > command. I need to catch the stdout of the commands in Pd, so I can > > monitor their status. Also, I want to be able to kill them > > individually. > > > > I tried to achieve that with [ggee/shell], but there are some > > culprits. > > > > When I launch the command directly in [shell] like this: > > > > [command ( > > > > > > > > [shell] > > > > I get the command's stdout on the left outlet of [shell], but I > > don't > > know of a reliable way to send a SIGHUP signal to command. > You could try to start the command and then execute > pidof command name > which should return the PID(s) of running commands, which you could > kill/hangup with yet another command. I tried that and it works to some degree, but it is very unreliable if have many instances of command running. I haven't found a _reliable_ way to assign many PIDs to individual commands. Also, I figured out that 'pidof' is not available per default on OS X and I'd like my patch work on both, Linux and OS X. If there'd be a way to send a SIGHUP (Ctrl-C) to the currently running command, it would make things a lot easier, but [shell] tries to start another process instead of directing the ASCII DEC 3 to command. > Not totally on-topic, but after a discussion with a friend yesterday > I > am curious if the functionality of ggee/shell can't be achieved with > pd-send and pd-receive as well? Yes, maybe, though I don't see how this would facilitate things. You would have to write a script that parses the output of pdreceive and performs some actions accordingly. But this would be insane to do in bash, I'd rather do it in python, then. Roman signature.asc Description: This is a digitally signed message part ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Re: [PD] Control external command from Pd
On Thu, 2016-12-01 at 11:37 +0100, Jack wrote: > Le 01/12/2016 à 11:30, Roman Haefeli a écrit : > > > > On Thu, 2016-12-01 at 11:09 +0100, Jack wrote: > > > > > > Hello Roman, > > > > > > Did you try : > > > > > > [command & echo $!( > > > > > > > > > > > > > > > [shell] > > > > > > It will return the pid of 'command'. > > Yes, you're right: It's not even necessary to put that into an > > extra > > script (I thought I had to because of the dollar sign). > > > > However, the problem remains: When I send 'command' to background, > > [shell] won't output its stdout to the left outlet anymore. > Hmm, weird, did you get something with ? : > (start Pd from a directory where there are files and directories). > > [ls & echo $!( > > > > > [shell] Yes, that works for me, too. But it's not a good example, since ls is a one shot command and exits immediately. Try this: [ping netpd.org & echo $!( The actual command I'm interested to work with is 'jacktrip'. Roman signature.asc Description: This is a digitally signed message part ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Re: [PD] Control external command from Pd
Le 01/12/2016 à 11:30, Roman Haefeli a écrit : > On Thu, 2016-12-01 at 11:09 +0100, Jack wrote: >> Hello Roman, >> >> Did you try : >> >> [command & echo $!( >>> >>> >> [shell] >> >> It will return the pid of 'command'. > > Yes, you're right: It's not even necessary to put that into an extra > script (I thought I had to because of the dollar sign). > > However, the problem remains: When I send 'command' to background, > [shell] won't output its stdout to the left outlet anymore. Hmm, weird, did you get something with ? : (start Pd from a directory where there are files and directories). [ls & echo $!( | [shell] | [print] ++ Jack > > Roman > > >> Le 01/12/2016 à 10:52, Roman Haefeli a écrit : >>> >>> Hey all >>> >>> I would like to use Pd to start and stop several instances of a >>> certain >>> command. I need to catch the stdout of the commands in Pd, so I can >>> monitor their status. Also, I want to be able to kill them >>> individually. >>> >>> I tried to achieve that with [ggee/shell], but there are some >>> culprits. >>> >>> When I launch the command directly in [shell] like this: >>> >>> [command ( >>> [shell] >>> >>> I get the command's stdout on the left outlet of [shell], but I >>> don't >>> know of a reliable way to send a SIGHUP signal to command. >>> >>> On the other, I can launch a wrapper script that sends command to >>> the >>> background and returns its PID: >>> >>> #!/bin/sh >>> command & >>> echo $! >>> >>> and in Pd, I do: >>> >>> [./wrapper.sh ( >>> [shell] >>> >>> and the left outlet of [shell] gives me the PID of the command >>> which >>> allows me to reliably kill that instance later. However, this way >>> [shell] doesn't output the command's stdout. >>> >>> Is there a way to have my cake and eat it, too? >>> >>> Roman >>> >>> >>> >>> ___ >>> Pd-list@lists.iem.at mailing list >>> UNSUBSCRIBE and account-management -> https://lists.puredata.info/l >>> istinfo/pd-list >>> >> >> ___ >> Pd-list@lists.iem.at mailing list >> UNSUBSCRIBE and account-management -> https://lists.puredata.info/lis >> tinfo/pd-list >> >> >> ___ >> Pd-list@lists.iem.at mailing list >> UNSUBSCRIBE and account-management -> >> https://lists.puredata.info/listinfo/pd-list signature.asc Description: OpenPGP digital signature ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Re: [PD] Control external command from Pd
On Thu, 2016-12-01 at 11:09 +0100, Jack wrote: > Hello Roman, > > Did you try : > > [command & echo $!( > > > > > [shell] > > It will return the pid of 'command'. Yes, you're right: It's not even necessary to put that into an extra script (I thought I had to because of the dollar sign). However, the problem remains: When I send 'command' to background, [shell] won't output its stdout to the left outlet anymore. Roman > Le 01/12/2016 à 10:52, Roman Haefeli a écrit : > > > > Hey all > > > > I would like to use Pd to start and stop several instances of a > > certain > > command. I need to catch the stdout of the commands in Pd, so I can > > monitor their status. Also, I want to be able to kill them > > individually. > > > > I tried to achieve that with [ggee/shell], but there are some > > culprits. > > > > When I launch the command directly in [shell] like this: > > > > [command ( > > > > > > > > [shell] > > > > I get the command's stdout on the left outlet of [shell], but I > > don't > > know of a reliable way to send a SIGHUP signal to command. > > > > On the other, I can launch a wrapper script that sends command to > > the > > background and returns its PID: > > > > #!/bin/sh > > command & > > echo $! > > > > and in Pd, I do: > > > > [./wrapper.sh ( > > > > > > > > [shell] > > > > and the left outlet of [shell] gives me the PID of the command > > which > > allows me to reliably kill that instance later. However, this way > > [shell] doesn't output the command's stdout. > > > > Is there a way to have my cake and eat it, too? > > > > Roman > > > > > > > > ___ > > Pd-list@lists.iem.at mailing list > > UNSUBSCRIBE and account-management -> https://lists.puredata.info/l > > istinfo/pd-list > > > > ___ > Pd-list@lists.iem.at mailing list > UNSUBSCRIBE and account-management -> https://lists.puredata.info/lis > tinfo/pd-list signature.asc Description: This is a digitally signed message part ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Re: [PD] Control external command from Pd
* Roman Haefeli[2016-12-01 10:52]: > Hey all > > I would like to use Pd to start and stop several instances of a certain > command. I need to catch the stdout of the commands in Pd, so I can > monitor their status. Also, I want to be able to kill them > individually. > > I tried to achieve that with [ggee/shell], but there are some > culprits. > > When I launch the command directly in [shell] like this: > > [command ( > | > [shell] > > I get the command's stdout on the left outlet of [shell], but I don't > know of a reliable way to send a SIGHUP signal to command. You could try to start the command and then execute pidof command name which should return the PID(s) of running commands, which you could kill/hangup with yet another command. Not totally on-topic, but after a discussion with a friend yesterday I am curious if the functionality of ggee/shell can't be achieved with pd-send and pd-receive as well? Peter ___ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list