Fixed subprocess code
This commit is contained in:
Binary file not shown.
7
main.py
7
main.py
@ -71,6 +71,8 @@ async def update_post(id: int, post: Post):
|
||||
my_posts[index] = post_dict
|
||||
return {"data": post_dict}
|
||||
|
||||
|
||||
|
||||
@app.get("/list")
|
||||
async def ping_host():
|
||||
# send one packet of data to the host
|
||||
@ -79,6 +81,7 @@ async def ping_host():
|
||||
# Iterate over all the servers in the list and ping each server
|
||||
# get the output as a string
|
||||
#output = str(os.system(cmd))
|
||||
output = subprocess.run(["/bin/ls", "-l"],stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
cmd = subprocess.run(["/bin/ls", "-al"],stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True, text=True)
|
||||
# store the output in the list
|
||||
output2 = (f"{output.stdout}")
|
||||
output = (f"{cmd.stdout}")
|
||||
return output
|
||||
Reference in New Issue
Block a user