I am writing a Python CGI script that I want to run on my laptop's browser. This script will SSH into two Pis, and give the command to take a photo. The server hosting this script is on one of the Pis that I want to SSH into, and that Pi also is acting as an access point for the other Pi and my laptop to connect to (everything is a LAN, not connected to the Internet).
I am successfully able to run this script on my laptop's browser to run simple commands like
ls -l on both Pis and print out the results for both on the browser. But, I ultimately want to be able to give the
raspistill command to both Pis. When I do this, only the Pi with the server is taking the image, but the other Pi is not. I assume it's because permissions aren't set properly for the server (I tried running the commands as
sudo but still no luck). However, if I run the same script on a Python IDLE it works fine. Can somebody help me identify the issue?
Here is my script:
#! /usr/bin/env python3 from pssh import ParallelSSHClient import cgi print("Content-Type: text/plain\r\n") print("\r\n ") host = ['172.24.1.1','172.24.1.112'] user = 'XXXX' password = 'XXXX' client = ParallelSSHClient(host, user, password) output = client.run_command('raspistill -o test.jpg', sudo=True) // AMENDMENT: for line in output['172.24.1.1'].stdout: //also works with other IP addr. print(line)
Apparently, if I output anything from the
stdout, both pictures are taken and show up in the respective directories. I now suspect this might be a issue with the pssh package I am using. It might be waiting for me output something, but I don't know why? Does anyone know why this might be?