I need to run and release a program in the background

Hi All,

How do I use qqx or other to run and release a
program in the background, like bash's "&"?

Many thanks,
-T

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A computer without Microsoft is like
a chocolate cake without the mustard
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0
perl6
11/14/2020 8:23:45 PM
perl.perl6.users 1505 articles. 0 followers. Follow

5 Replies
12 Views

Similar Articles

[PageSpeed] 35

On 2020-11-14 12:23, ToddAndMargo via perl6-users wrote:
> Hi All,
> 
> How do I use qqx or other to run and release a
> program in the background, like bash's "&"?
> 
> Many thanks,
> -T
> 

The guys on hte chat line figured it out for me:

$ p6 'my $pA = Proc::Async.new( "/usr/bin/leafpad" ); my $promise = 
$pA.start;'
0
perl6
11/14/2020 9:14:38 PM
On 2020-11-14 13:14, ToddAndMargo via perl6-users wrote:
> On 2020-11-14 12:23, ToddAndMargo via perl6-users wrote:
>> Hi All,
>>
>> How do I use qqx or other to run and release a
>> program in the background, like bash's "&"?
>>
>> Many thanks,
>> -T
>>
> 
> The guys on hte chat line figured it out for me:
> 
> $ p6 'my $pA = Proc::Async.new( "/usr/bin/leafpad" ); my $promise = 
> $pA.start;'


My keeper on the subject:


How to run and release a file:

Note: this command runs OUTSIDE the shell.  There are no
       environmental variables to be found such as $HOME

       the parpameters are in quotes, including the name of
       the program to run, just like `run`


$ p6 'my $pA = Proc::Async.new( "/usr/bin/leafpad" ); my $promise = 
$pA.start; await $promise;'
$ p6 'my $pA = Proc::Async.new( "/usr/bin/leafpad" ); $pA.start;'
$ p6 'my $pA = Proc::Async.new( "/usr/bin/leafpad", 
"/home/linuxutil/XferParts.pl6.tmp" ); $pA.start;'


To get this to run with the shell, call "bash -c"
my $pA = Proc::Async.new( "bash", "-c", "/usr/bin/leafpad 
/home/linuxutil/XferParts.pl6.tmp" );  $pA.start;
0
perl6
11/14/2020 10:37:25 PM
On 2020-11-14 12:23, ToddAndMargo via perl6-users wrote:
> Hi All,
> 
> How do I use qqx or other to run and release a
> program in the background, like bash's "&"?
> 
> Many thanks,
> -T
> 


My revised keeper:

How to run and release a file:

Note: this command runs OUTSIDE the shell.  There are no
       environmental variables to be found such as $HOME

       the parameters are in quotes, including the name of
       the program to run, just like `run`

$ p6 'my $pA = Proc::Async.new( "/usr/bin/leafpad" ); my $promise = 
$pA.start; await $promise;'
$ p6 'my $pA = Proc::Async.new( "/usr/bin/leafpad" ); $pA.start;'
$ p6 'my $pA = Proc::Async.new( '/usr/bin/leafpad 
"/home/linuxutil/XferParts.pl6.tmp"' ); $pA.start;'


To get this to run with the shell, call "bash -c".
   Note: all the parameters to the command bash executing
         with "-c" go into an embedded quote stream.
         For example:

             '/usr/bin/leafpad "/home/linuxutil/XferParts.pl6.tmp"'

    my $pA = Proc::Async.new( "bash", "-c", '/usr/bin/leafpad 
"/home/linuxutil/XferParts.pl6.tmp"' );
    say $pA;
    $pA.start;

Proc::Async.new(path => "bash", args => ["-c", "/usr/bin/leafpad 
\"/home/linuxutil/XferParts.pl6.tmp\""], command => ("bash", "-c", 
"/usr/bin/leafpad  \"/home/linuxutil/XferParts.pl6.tmp\""), w => Any, 
enc => "utf8", translate-nl => Bool::True, win-verbatim-args => 
Bool::False, started => Bool::False)
0
perl6
11/16/2020 10:39:26 PM
--_000_SJ0PR09MB7375B9E78C70D34523A986FAC0E30SJ0PR09MB7375namp_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

> this command runs OUTSIDE the shell.  There are no  environmental variabl=
es to be found such as $HOME

Well, not exactly none, but a limited env

$ raku -e 'my $pA =3D Proc::Async.new( "env" ); $pA.start;'
TERM=3Dxterm
XDG_RUNTIME_DIR=3D/run/user/1000
XDG_SESSION_TYPE=3Dtty
LESSCLOSE=3D/usr/bin/lesspipe %s %s
COMP_WORDBREAKS=3D
"'><;|&(:
LANG=3Den_US.UTF-8
SSH_CLIENT=3D10.222.64.247 65064 22
SHLVL=3D1
GOARCH=3D386
XDG_DATA_DIRS=3D/home/andy/.local/share/flatpak/exports/share:/var/lib/flat=
pak/exports/share:/usr/local/share:/usr/share
USER=3Dandy
SSH_TTY=3D/dev/pts/1
XDG_SESSION_CLASS=3Duser
LS_COLORS=3Drs=3D0:di=3D01;34:ln=3D01;36:mh=3D00:pi=3D40;33:so=3D01;35:do=
=3D01;35:bd=3D40;33;01:cd=3D40;33;01:or=3D40;31;01:mi=3D00:su=3D37;41:sg=3D=
30;43:ca=3D30;41:tw=3D30;42:ow=3D34;42:st=3D37;44:ex=3D01;32:*.tar=3D01;31:=
*.tgz=3D01;31:*.arc=3D01;31:*.arj=3D01;31:*.taz=3D01;31:*.lha=3D01;31:*.lz4=
=3D01;31:*.lzh=3D01;31:*.lzma=3D01;31:*.tlz=3D01;31:*.txz=3D01;31:*.tzo=3D0=
1;31:*.t7z=3D01;31:*.zip=3D01;31:*.z=3D01;31:*.dz=3D01;31:*.gz=3D01;31:*.lr=
z=3D01;31:*.lz=3D01;31:*.lzo=3D01;31:*.xz=3D01;31:*.zst=3D01;31:*.tzst=3D01=
;31:*.bz2=3D01;31:*.bz=3D01;31:*.tbz=3D01;31:*.tbz2=3D01;31:*.tz=3D01;31:*.=
deb=3D01;31:*.rpm=3D01;31:*.jar=3D01;31:*.war=3D01;31:*.ear=3D01;31:*.sar=
=3D01;31:*.rar=3D01;31:*.alz=3D01;31:*.ace=3D01;31:*.zoo=3D01;31:*.cpio=3D0=
1;31:*.7z=3D01;31:*.rz=3D01;31:*.cab=3D01;31:*.wim=3D01;31:*.swm=3D01;31:*.=
dwm=3D01;31:*.esd=3D01;31:*.jpg=3D01;35:*.jpeg=3D01;35:*.mjpg=3D01;35:*.mjp=
eg=3D01;35:*.gif=3D01;35:*.bmp=3D01;35:*.pbm=3D01;35:*.pgm=3D01;35:*.ppm=3D=
01;35:*.tga=3D01;35:*.xbm=3D01;35:*.xpm=3D01;35:*.tif=3D01;35:*.tiff=3D01;3=
5:*.png=3D01;35:*.svg=3D01;35:*.svgz=3D01;35:*.mng=3D01;35:*.pcx=3D01;35:*.=
mov=3D01;35:*.mpg=3D01;35:*.mpeg=3D01;35:*.m2v=3D01;35:*.mkv=3D01;35:*.webm=
=3D01;35:*.ogm=3D01;35:*.mp4=3D01;35:*.m4v=3D01;35:*.mp4v=3D01;35:*.vob=3D0=
1;35:*.qt=3D01;35:*.nuv=3D01;35:*.wmv=3D01;35:*.asf=3D01;35:*.rm=3D01;35:*.=
rmvb=3D01;35:*.flc=3D01;35:*.avi=3D01;35:*.fli=3D01;35:*.flv=3D01;35:*.gl=
=3D01;35:*.dl=3D01;35:*.xcf=3D01;35:*.xwd=3D01;35:*.yuv=3D01;35:*.cgm=3D01;=
35:*.emf=3D01;35:*.ogv=3D01;35:*.ogx=3D01;35:*.aac=3D00;36:*.au=3D00;36:*.f=
lac=3D00;36:*.m4a=3D00;36:*.mid=3D00;36:*.midi=3D00;36:*.mka=3D00;36:*.mp3=
=3D00;36:*.mpc=3D00;36:*.ogg=3D00;36:*.ra=3D00;36:*.wav=3D00;36:*.oga=3D00;=
36:*.opus=3D00;36:*.spx=3D00;36:*.xspf=3D00;36:
GOROOT=3D/home/andy/go
LOGNAME=3Dandy
MOTD_SHOWN=3Dpam
LESSOPEN=3D| /usr/bin/lesspipe %s
GOBIN=3D/home/andy/bin
_=3D/usr/bin/perl6
HOME=3D/home/andy
PWD=3D/home/andy
XDG_SESSION_ID=3D596
SHELL=3D/bin/bash
GOOS=3Dlinux
SSH_CONNECTION=3D10.222.64.247 65064 156.126.45.100 22
PATH=3D/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/ga=
mes:/usr/local/games:/snap/bin


________________________________
From: ToddAndMargo via perl6-users <perl6-users@perl.org>
Sent: Monday, November 16, 2020 4:39 PM
To: perl6-users@perl.org <perl6-users@perl.org>
Subject: Re: I need to run and release a program in the background

CAUTION - EXTERNAL:


On 2020-11-14 12:23, ToddAndMargo via perl6-users wrote:
> Hi All,
>
> How do I use qqx or other to run and release a
> program in the background, like bash's "&"?
>
> Many thanks,
> -T
>


My revised keeper:

How to run and release a file:

Note: this command runs OUTSIDE the shell.  There are no
       environmental variables to be found such as $HOME

       the parameters are in quotes, including the name of
       the program to run, just like `run`

$ p6 'my $pA =3D Proc::Async.new( "/usr/bin/leafpad" ); my $promise =3D
$pA.start; await $promise;'
$ p6 'my $pA =3D Proc::Async.new( "/usr/bin/leafpad" ); $pA.start;'
$ p6 'my $pA =3D Proc::Async.new( '/usr/bin/leafpad
"/home/linuxutil/XferParts.pl6.tmp"' ); $pA.start;'


To get this to run with the shell, call "bash -c".
   Note: all the parameters to the command bash executing
         with "-c" go into an embedded quote stream.
         For example:

             '/usr/bin/leafpad "/home/linuxutil/XferParts.pl6.tmp"'

    my $pA =3D Proc::Async.new( "bash", "-c", '/usr/bin/leafpad
"/home/linuxutil/XferParts.pl6.tmp"' );
    say $pA;
    $pA.start;

Proc::Async.new(path =3D> "bash", args =3D> ["-c", "/usr/bin/leafpad
\"/home/linuxutil/XferParts.pl6.tmp\""], command =3D> ("bash", "-c",
"/usr/bin/leafpad  \"/home/linuxutil/XferParts.pl6.tmp\""), w =3D> Any,
enc =3D> "utf8", translate-nl =3D> Bool::True, win-verbatim-args =3D>
Bool::False, started =3D> Bool::False)
CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exer=
cise caution when opening attachments or clicking on links.


--_000_SJ0PR09MB7375B9E78C70D34523A986FAC0E30SJ0PR09MB7375namp_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<style type=3D"text/css" style=3D"display:none;"> P {margin-top:0;margin-bo=
ttom:0;} </style>
</head>
<body dir=3D"ltr">
<div style=3D"font-family: &quot;Times New Roman&quot;, Times, serif; font-=
size: 12pt; color: rgb(0, 0, 0);">
&gt;&nbsp;<span style=3D"font-family:&quot;Segoe UI&quot;, &quot;Segoe UI W=
eb (West European)&quot;, &quot;Segoe UI&quot;, -apple-system, BlinkMacSyst=
emFont, Roboto, &quot;Helvetica Neue&quot;, sans-serif;font-size:14.6667px;=
background-color:rgb(255, 255, 255);display:inline !important">this command=
 runs OUTSIDE
 the shell.&nbsp; There are no&nbsp;</span><span style=3D"font-family:&quot=
;Segoe UI&quot;, &quot;Segoe UI Web (West European)&quot;, &quot;Segoe UI&q=
uot;, -apple-system, BlinkMacSystemFont, Roboto, &quot;Helvetica Neue&quot;=
, sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);displa=
y:inline !important">&nbsp;environmental
 variables to be found such as $HOME</span></div>
<div style=3D"font-family: &quot;Times New Roman&quot;, Times, serif; font-=
size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style=3D"font-family: &quot;Times New Roman&quot;, Times, serif; font-=
size: 12pt; color: rgb(0, 0, 0);">
Well, not exactly none, but a limited env</div>
<div style=3D"font-family: &quot;Times New Roman&quot;, Times, serif; font-=
size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style=3D"font-family: &quot;Times New Roman&quot;, Times, serif; font-=
size: 12pt; color: rgb(0, 0, 0);">
$ raku&nbsp;-e 'my $pA =3D Proc::Async.new( &quot;env&quot; ); $pA.start;'
<div>TERM=3Dxterm</div>
<div>XDG_RUNTIME_DIR=3D/run/user/1000</div>
<div>XDG_SESSION_TYPE=3Dtty</div>
<div>LESSCLOSE=3D/usr/bin/lesspipe %s %s</div>
<div>COMP_WORDBREAKS=3D</div>
<div>&quot;'&gt;&lt;;|&amp;(:</div>
<div>LANG=3Den_US.UTF-8</div>
<div>SSH_CLIENT=3D10.222.64.247 65064 22</div>
<div>SHLVL=3D1</div>
<div>GOARCH=3D386</div>
<div>XDG_DATA_DIRS=3D/home/andy/.local/share/flatpak/exports/share:/var/lib=
/flatpak/exports/share:/usr/local/share:/usr/share</div>
<div>USER=3Dandy</div>
<div>SSH_TTY=3D/dev/pts/1</div>
<div>XDG_SESSION_CLASS=3Duser</div>
<div>LS_COLORS=3Drs=3D0:di=3D01;34:ln=3D01;36:mh=3D00:pi=3D40;33:so=3D01;35=
:do=3D01;35:bd=3D40;33;01:cd=3D40;33;01:or=3D40;31;01:mi=3D00:su=3D37;41:sg=
=3D30;43:ca=3D30;41:tw=3D30;42:ow=3D34;42:st=3D37;44:ex=3D01;32:*.tar=3D01;=
31:*.tgz=3D01;31:*.arc=3D01;31:*.arj=3D01;31:*.taz=3D01;31:*.lha=3D01;31:*.=
lz4=3D01;31:*.lzh=3D01;31:*.lzma=3D01;31:*.tlz=3D01;31:*.txz=3D01;31:*.tzo=
=3D01;31:*.t7z=3D01;31:*.zip=3D01;31:*.z=3D01;31:*.dz=3D01;31:*.gz=3D01;31:=
*.lrz=3D01;31:*.lz=3D01;31:*.lzo=3D01;31:*.xz=3D01;31:*.zst=3D01;31:*.tzst=
=3D01;31:*.bz2=3D01;31:*.bz=3D01;31:*.tbz=3D01;31:*.tbz2=3D01;31:*.tz=3D01;=
31:*.deb=3D01;31:*.rpm=3D01;31:*.jar=3D01;31:*.war=3D01;31:*.ear=3D01;31:*.=
sar=3D01;31:*.rar=3D01;31:*.alz=3D01;31:*.ace=3D01;31:*.zoo=3D01;31:*.cpio=
=3D01;31:*.7z=3D01;31:*.rz=3D01;31:*.cab=3D01;31:*.wim=3D01;31:*.swm=3D01;3=
1:*.dwm=3D01;31:*.esd=3D01;31:*.jpg=3D01;35:*.jpeg=3D01;35:*.mjpg=3D01;35:*=
..mjpeg=3D01;35:*.gif=3D01;35:*.bmp=3D01;35:*.pbm=3D01;35:*.pgm=3D01;35:*.pp=
m=3D01;35:*.tga=3D01;35:*.xbm=3D01;35:*.xpm=3D01;35:*.tif=3D01;35:*.tiff=3D=
01;35:*.png=3D01;35:*.svg=3D01;35:*.svgz=3D01;35:*.mng=3D01;35:*.pcx=3D01;3=
5:*.mov=3D01;35:*.mpg=3D01;35:*.mpeg=3D01;35:*.m2v=3D01;35:*.mkv=3D01;35:*.=
webm=3D01;35:*.ogm=3D01;35:*.mp4=3D01;35:*.m4v=3D01;35:*.mp4v=3D01;35:*.vob=
=3D01;35:*.qt=3D01;35:*.nuv=3D01;35:*.wmv=3D01;35:*.asf=3D01;35:*.rm=3D01;3=
5:*.rmvb=3D01;35:*.flc=3D01;35:*.avi=3D01;35:*.fli=3D01;35:*.flv=3D01;35:*.=
gl=3D01;35:*.dl=3D01;35:*.xcf=3D01;35:*.xwd=3D01;35:*.yuv=3D01;35:*.cgm=3D0=
1;35:*.emf=3D01;35:*.ogv=3D01;35:*.ogx=3D01;35:*.aac=3D00;36:*.au=3D00;36:*=
..flac=3D00;36:*.m4a=3D00;36:*.mid=3D00;36:*.midi=3D00;36:*.mka=3D00;36:*.mp=
3=3D00;36:*.mpc=3D00;36:*.ogg=3D00;36:*.ra=3D00;36:*.wav=3D00;36:*.oga=3D00=
;36:*.opus=3D00;36:*.spx=3D00;36:*.xspf=3D00;36:</div>
<div>GOROOT=3D/home/andy/go</div>
<div>LOGNAME=3Dandy</div>
<div>MOTD_SHOWN=3Dpam</div>
<div>LESSOPEN=3D| /usr/bin/lesspipe %s</div>
<div>GOBIN=3D/home/andy/bin</div>
<div>_=3D/usr/bin/perl6</div>
<div>HOME=3D/home/andy</div>
<div>PWD=3D/home/andy</div>
<div>XDG_SESSION_ID=3D596</div>
<div>SHELL=3D/bin/bash</div>
<div>GOOS=3Dlinux</div>
<div>SSH_CONNECTION=3D10.222.64.247 65064 156.126.45.100 22</div>
<div>PATH=3D/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/u=
sr/games:/usr/local/games:/snap/bin</div>
<div><br>
</div>
<br>
</div>
<div id=3D"appendonsend"></div>
<hr style=3D"display:inline-block;width:98%" tabindex=3D"-1">
<div id=3D"divRplyFwdMsg" dir=3D"ltr"><font face=3D"Calibri, sans-serif" st=
yle=3D"font-size:11pt" color=3D"#000000"><b>From:</b> ToddAndMargo via perl=
6-users &lt;perl6-users@perl.org&gt;<br>
<b>Sent:</b> Monday, November 16, 2020 4:39 PM<br>
<b>To:</b> perl6-users@perl.org &lt;perl6-users@perl.org&gt;<br>
<b>Subject:</b> Re: I need to run and release a program in the background</=
font>
<div>&nbsp;</div>
</div>
<div class=3D"BodyFragment"><font size=3D"2"><span style=3D"font-size:11pt;=
">
<div class=3D"PlainText">CAUTION - EXTERNAL:<br>
<br>
<br>
On 2020-11-14 12:23, ToddAndMargo via perl6-users wrote:<br>
&gt; Hi All,<br>
&gt;<br>
&gt; How do I use qqx or other to run and release a<br>
&gt; program in the background, like bash's &quot;&amp;&quot;?<br>
&gt;<br>
&gt; Many thanks,<br>
&gt; -T<br>
&gt;<br>
<br>
<br>
My revised keeper:<br>
<br>
How to run and release a file:<br>
<br>
Note: this command runs OUTSIDE the shell.&nbsp; There are no<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; environmental variables to be found su=
ch as $HOME<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the parameters are in quotes, includin=
g the name of<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the program to run, just like `run`<br=
>
<br>
$ p6 'my $pA =3D Proc::Async.new( &quot;/usr/bin/leafpad&quot; ); my $promi=
se =3D<br>
$pA.start; await $promise;'<br>
$ p6 'my $pA =3D Proc::Async.new( &quot;/usr/bin/leafpad&quot; ); $pA.start=
;'<br>
$ p6 'my $pA =3D Proc::Async.new( '/usr/bin/leafpad<br>
&quot;/home/linuxutil/XferParts.pl6.tmp&quot;' ); $pA.start;'<br>
<br>
<br>
To get this to run with the shell, call &quot;bash -c&quot;.<br>
&nbsp;&nbsp; Note: all the parameters to the command bash executing<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; with &quot;-c&quot; go int=
o an embedded quote stream.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For example:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '/=
usr/bin/leafpad &quot;/home/linuxutil/XferParts.pl6.tmp&quot;'<br>
<br>
&nbsp;&nbsp;&nbsp; my $pA =3D Proc::Async.new( &quot;bash&quot;, &quot;-c&q=
uot;, '/usr/bin/leafpad<br>
&quot;/home/linuxutil/XferParts.pl6.tmp&quot;' );<br>
&nbsp;&nbsp;&nbsp; say $pA;<br>
&nbsp;&nbsp;&nbsp; $pA.start;<br>
<br>
Proc::Async.new(path =3D&gt; &quot;bash&quot;, args =3D&gt; [&quot;-c&quot;=
, &quot;/usr/bin/leafpad<br>
\&quot;/home/linuxutil/XferParts.pl6.tmp\&quot;&quot;], command =3D&gt; (&q=
uot;bash&quot;, &quot;-c&quot;,<br>
&quot;/usr/bin/leafpad&nbsp; \&quot;/home/linuxutil/XferParts.pl6.tmp\&quot=
;&quot;), w =3D&gt; Any,<br>
enc =3D&gt; &quot;utf8&quot;, translate-nl =3D&gt; Bool::True, win-verbatim=
-args =3D&gt;<br>
Bool::False, started =3D&gt; Bool::False)<br>
CAUTION - EXTERNAL EMAIL: This email originated outside the Judiciary. Exer=
cise caution when opening attachments or clicking on links.<br>
<br>
</div>
</span></font></div>
</body>
</html>

--_000_SJ0PR09MB7375B9E78C70D34523A986FAC0E30SJ0PR09MB7375namp_--
0
Andy_Bach
11/16/2020 11:50:07 PM
On 2020-11-16 15:50, Andy Bach wrote:
>  > this command runs OUTSIDE the shell.=C2=A0 There are no =C2=A0enviro=
nmental=20
> variables to be found such as $HOME
>=20
> Well, not exactly none, but a limited env
>=20
> $ raku=C2=A0-e 'my $pA =3D Proc::Async.new( "env" ); $pA.start;'

=2E..

Hi Andy,

Limited indeed!  I get around it with:

my Str $Leafpadrc =3D $*HOME ~ "/" ~ ".config/leafpad/leafpadrc";


:-)

-T
0
perl6
11/17/2020 12:18:47 AM
Reply: