I have a set of servers and I want to launch a dedicated Python script on each one. My computer name list is stored into a $COMPUTERS variable, and to deploy my script, I am trying to connect using SSH and launch a screen instance
for ((i = 0; i < ${#COMPUTERS[@]}; i )); do
echo ""
echo ">> Start simulations on computer ${COMPUTERS[i]}..."
ssh -o "StrictHostKeyChecking=accept-new" ${COMPUTERS[i]} "
cd ${WORKING_DIRECTORY}/compressor && git pull;
screen -S ${SCREEN_NAME} -X quit > /dev/null;
echo 'Start screen ${SCREEN_NAME} on ${COMPUTERS[i]}';
screen -dmS ${SCREEN_NAME} ' \
export LD_LIBRARY_PATH=\"${LD_LIBRARY_PATH}:${WORKING_DIRECTORY}/venv/lib/\" && \
${WORKING_DIRECTORY}/venv/bin/python ${WORKING_DIRECTORY}/deployment/simulations/simulate.py ${i} > ~/output_${COMPUTERS[i]}.txt \
';
screen -r;
"
echo "Done for ${COMPUTERS[i]}"
done
But, no screen instance is launched, and the only message I have is :
Start screen sim on pc-elec.priv
Must be connected to a terminal.
CodePudding user response:
You need to force Pseudo terminal.
-t' Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.
For Example:
ssh -t -o "StrictHostKeyChecking=accept-new" ${COMPUTERS[i]}