Created
January 7, 2026 18:06
-
-
Save mainframed/b864a2f176cabaa4feae13a2114a9650 to your computer and use it in GitHub Desktop.
Run a REXX script through SSH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Store password securely (file with 600 permissions) | |
| # echo "yourpassword" > ~/.ssh/z_pass | |
| # chmod 600 ~/.ssh/z_pass | |
| PASSWORD=$(cat ~/.ssh/z_pass) | |
| # List of LPARs | |
| LPARS=("lpar1" "lpar2" "lpar3") | |
| # REXX script content | |
| REXX_SCRIPT='/* your rexx code here */ | |
| SAY "Script running" | |
| ' | |
| for lpar in "${LPARS[@]}"; do | |
| echo "Processing $lpar..." | |
| # Upload REXX script | |
| echo "$REXX_SCRIPT" | sshpass -p "$PASSWORD" ssh user@$lpar "cat > /tmp/netspi_apf.rexx" | |
| # Make executable, run, get output, delete | |
| sshpass -p "$PASSWORD" ssh user@$lpar "chmod +x /tmp/netspi_apf.rexx && /tmp/netspi_apf.rexx > /tmp/output.txt 2>&1 && cat /tmp/output.txt && rm /tmp/netspi_apf.rexx /tmp/output.txt" > "${lpar}_output.txt" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment