I am writing scripts to poll a large number of remote hosts over ssh using gnu parallel. I copy the script to them, run it and get the results. Right now I'm using two bundles parallel + scp to transfer the file, and parallel + ssh to get the result. But I can't figure out how to implement this with one bundle of parallel + ssh, simultaneously transfer the file and get the result.
parallel --tagstring {} -j 25 -q -a file_ip_addr_hosts.csv\
sshpass -p pass ssh user@{}\
'cat > file_for_send.sh && source file_for_send.sh && echo result' < file_for_send.sh
It is clear that the file is being created, but it is empty.
Everything works fine without using gnu parallel.
My task is to copy and execute a file on multiple hosts using parallel with one command.
< file_for_send.sh
is attached to the stdin ofparallel
. Even if this stdin ultimately is inherited byssh
(and I don't know if it is), it's not that eachssh
will reopen the file and read it from the beginning. Write a script that takes (at least)user@server
as an argument and handles a single case ofssh
inside, including the redirection fromfile_for_send.sh
. Then letparallel
run the script multiple times. Maybe there is a clever option forparallel
to fork (tee
-like) its stdin, but I don't know the tool good enough to tell.