i have a problem regarding running an ssh command while inside "function"
script structure
#!/usr/bin/bash
func1(){
script=$1
ssh user@server "$script"
}
cat script.txt | while read line
do
func1 $line
done
exit 0
the problem is when ssh ran, the "while read line" seems to just read the first line of the file and proceed with "exit 0"
but its working well when ssh was replace with some other command like "echo"
the remotely executed script doesnt contain "exit" command, so no way the remote script will end the parent script.
anyone has an idea?