Commit 6d55d715 authored by epsi sayidina's avatar epsi sayidina

standalone

parent 05c2e55e
......@@ -16,7 +16,7 @@ my $pipein = IO::Pipe->new();
my $hnd_in = $pipein->reader($cmdin);
my $pipeout = IO::Pipe->new();
my $hnd_ou = $pipeout->writer($cmdout);
my $hnd_out = $pipeout->writer($cmdout);
while(<$pipein>) {
print $pipeout $_;
......
#!/usr/bin/perl
# Unidirectional Pipe Example
# A pipe has a read end and a write end.
use warnings;
use strict;
use File::Basename;
my $dirname = dirname(__FILE__);
my $path = "$dirname/../assets";
my $cmdin = "conky -c $path/conky.lua";
my $cmdout = "less"; # or dzen2
open my $pipein, "-|", $cmdin
or die "Could not open filehandle: $!";
open my $pipeout, "|-", $cmdout
or die "Could not open filehandle: $!";
while(<$pipein>) {
print $pipeout $_;
flush $pipeout;
}
close $pipein;
close $pipeout;
#!/usr/bin/env python3
# https://pymotw.com/2/subprocess/
import os
import subprocess
dirname = os.path.dirname(os.path.abspath(__file__))
path = dirname + "/../assets"
cmdin = 'conky -c ' + path + '/conky.lua'
cmdout = 'less -K' # or 'dzen2'
pipein = subprocess.Popen(
[cmdin],
stdout = subprocess.PIPE,
stderr = subprocess.STDOUT,
shell = True,
universal_newlines = True
)
pipeout = subprocess.Popen(
[cmdout],
stdin = pipein.stdout,
shell = True,
universal_newlines = True
)
# http://kendriu.com/how-to-use-pipes-in-python-subprocesspopen-objects
pipein.stdout.close()
outputs, errors = pipeout.communicate()
# avoid zombie apocalypse
pipeout.wait()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment