Jan-03-2019, 04:29 AM
I am using this both on my macosx and linux and it works well.
On linux the shell commands are slightly different:
vlc -I oldrc --rc-unix=/home/user/Documents/Sockets/socket1.sock
vlc -I oldrc --rc-unix=/home/user/Documents/Sockets/socket2.sock
and
echo play | nc -U /home/user/Documents/Sockets/socket1.sock
echo enqueue /home/user/Documents/DualscreenVLC/videos/MVI_2534.MP4 | nc -U /home/user/Documents/Sockets/socket1.sock
I am attempting to use subprocess.Popen in Python for further control but here I run into difficulties on Linux (Ubuntu). It either hangs on the stdout.read() call or when I take this away, all the shell commands are only executed after the script finishes and I get a broken pipe error. The issue seems to be specifically with the 'echo' commands. Did I migrate wrong?
This is the python script:
On linux the shell commands are slightly different:
vlc -I oldrc --rc-unix=/home/user/Documents/Sockets/socket1.sock
vlc -I oldrc --rc-unix=/home/user/Documents/Sockets/socket2.sock
and
echo play | nc -U /home/user/Documents/Sockets/socket1.sock
echo enqueue /home/user/Documents/DualscreenVLC/videos/MVI_2534.MP4 | nc -U /home/user/Documents/Sockets/socket1.sock
I am attempting to use subprocess.Popen in Python for further control but here I run into difficulties on Linux (Ubuntu). It either hangs on the stdout.read() call or when I take this away, all the shell commands are only executed after the script finishes and I get a broken pipe error. The issue seems to be specifically with the 'echo' commands. Did I migrate wrong?
This is the python script:
import subprocess import time Socket1Location = "/Users/user/socket1.sock" Socket2Location = "/Users/user/socket2.sock" video1 = "/Users/user/Documents/Scripts/DualscreenVLC/videos/video01.mp4" video2 = "/Users/user/Documents/Scripts/DualscreenVLC/videos/video02.mp4" def RunVLCCommand1(cmd): p = subprocess.Popen("echo " + cmd + " | nc -U " + Socket1Location, shell = True, stdout = subprocess.PIPE) errcode = p.wait() retval = p.stdout.read() print "returning: " + retval return retval def RunVLCCommand2(cmd): p = subprocess.Popen("echo " + cmd + " | nc -U " + Socket2Location, shell = True, stdout = subprocess.PIPE) errcode = p.wait() retval = p.stdout.read() print "returning: " + retval return retval subprocess.Popen(["/Applications/VLC.app/Contents/MacOS/VLC","--rc-unix=/Users/user/socket1.sock"]) subprocess.Popen(["/Applications/VLC.app/Contents/MacOS/VLC","--rc-unix=/Users/user/socket2.sock"]) #RunVLCCommand1 and 2 can now be used to send commands to VLC, for example RunVLCCommand1('play')