This
import pexpectdef run(cmd, stdin): child = pexpect.spawn(cmd, encoding='utf-8') child.send(stdin) child.sendeof()run('xclip -selection clipboard', 'lol')
should copy string lol
into my clipboard, so that I paste it around by Ctrl+v.
But, instead, I get the behaviour of echo -n '' | xclip -selection clipboard
i.e. the behaviour of passing empty file as STDIN into xclip
.
Why?
UPDATE
This prints lollxl
instead of just lxl
:
import pexpectdef run(cmd, stdin): child = pexpect.spawn(cmd, encoding='utf-8') child.send(stdin) child.sendeof() child.sendeof() x = child.read() child.wait() return xx = run("sed --expression='s/o/x/g'", 'lol')print(x)