-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·37 lines (29 loc) · 919 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
import sys
import subprocess
import array as arr
import argparse
import os
import shlex
def which(pgm):
path=os.getenv('PATH')
for p in path.split(os.path.pathsep):
p=os.path.join(p,pgm)
if os.path.exists(p) and os.access(p,os.X_OK):
return p
def check_exists(pgm):
if which(pgm) == None:
print(pgm, "not on path")
def run_command_locally(command):
print("command=",command)
subprocess.run(shlex.split(command), check=True)
starting_dir = os.getcwd()
print("path to script=",os.path.dirname(os.path.realpath(__file__)))
print("starting_dir =",starting_dir)
run_command_locally("ls -l")
import subprocess
#ls_output=subprocess.Popen(["sleep", "5"])
#ls_output.communicate() # Will block for 30 seconds
ls_output=subprocess.Popen(["python3", "./EchoServer.py"])
run_command_locally("python3 ./EchoClient.py")
ls_output.communicate()