Fixed subprocess code
This commit is contained in:
Binary file not shown.
9
main.py
9
main.py
@ -71,6 +71,8 @@ async def update_post(id: int, post: Post):
|
|||||||
my_posts[index] = post_dict
|
my_posts[index] = post_dict
|
||||||
return {"data": post_dict}
|
return {"data": post_dict}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/list")
|
@app.get("/list")
|
||||||
async def ping_host():
|
async def ping_host():
|
||||||
# send one packet of data to the host
|
# send one packet of data to the host
|
||||||
@ -78,7 +80,8 @@ async def ping_host():
|
|||||||
outputlist = []
|
outputlist = []
|
||||||
# Iterate over all the servers in the list and ping each server
|
# Iterate over all the servers in the list and ping each server
|
||||||
# get the output as a string
|
# get the output as a string
|
||||||
# output = str(os.system(cmd))
|
#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
|
# store the output in the list
|
||||||
output2 = (f"{output.stdout}")
|
output = (f"{cmd.stdout}")
|
||||||
|
return output
|
||||||
Reference in New Issue
Block a user