0

I have a requirement to go to multiple servers and execute several commands, and I thought of using pssh, which I would like to encapsulate in a script, but it doesn't seem to work

# script.sh

cmd1(){
  command2 $1 $2
}

cmd2(){
  command2 $1
}
...
...

main(){
  cmd1 "$1" "$2"
  cmd2 "$2"
  ...
  ...
}

main "$@"

The errors in pssh -ih testhost -P < ./script.sh -X para1 para2 are as follows

[1] 07:20:26 [FAILURE] 104.218.165.140 Exited with error code 127
Stderr: bash: arg1: command not found

Is this a case of pssh not being able to execute scripts and carry parameters? If not, then how do I change it, and if so, is there another suitable tool or method to implement what I need (to access multiple servers and execute multiple commands).

I really appreciate any help with this.

moluzhui
  • 1,003
  • 14
  • 34

0 Answers0