SSH [SOLVED]: ssh in bash script exits loop Home › Forums › SSH › SSH [SOLVED]: ssh in bash script exits loop Tagged: bash, ssh, stdin Viewing 2 posts - 1 through 2 (of 2 total) Author Posts December 20, 2017 at 2:35 am #36070 Anonymous Question I am trying to run some commands on few remote hosts. I have the list of their ips in a file ips.txt (one ip per line). #!/bin/bash while IFS= read -r wip; do echo $wip ssh root@$wip "pkill pgm; cd /root/pgm; nohup ./pgm > /dev/null 2>&1 &" echo "$wip end" done < ips.txt I am running the above script. But the problem is after reading the first ip the loop exits. But if i remove the ssh line, it prints all ips. December 20, 2017 at 2:35 am #36071 Anonymous Answer ssh reads everything from stdin (ips.txt). Replace ssh with ssh -n See: man ssh Source: https://stackoverflow.com/questions/47858222/ssh-in-bash-script-exits-loopAuthor: CyrusThis work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Author Posts Viewing 2 posts - 1 through 2 (of 2 total) You must be logged in to reply to this topic.