-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create script to run commands on targets
- Loading branch information
1 parent
04ef509
commit 03b2736
Showing
3 changed files
with
133 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { input, lines } from "std" | ||
|
||
let cmd = input("Enter the command to run: ") | ||
|
||
let x = $cat "./targets.yaml" | grep "ws://"$ failed { | ||
echo "[{status}] Failed to read file" | ||
} | ||
|
||
let attempted = 0 | ||
let succeeded = 0 | ||
|
||
loop index, line in lines(x) { | ||
let ip = $echo {line} | cut -b 8- | rev | cut -b 6- | rev$ failed { | ||
echo "[{status}] failed to extract ip from {line}" | ||
} | ||
echo "Running on target {index} at {ip}" | ||
attempted = attempted + 1 | ||
let result = $ssh "-oPreferredAuthentications publickey" "root@{ip}" {cmd}$ failed { | ||
succeeded = succeeded - 1 | ||
echo "[{status}] failed to run command on {ip}" | ||
} | ||
|
||
succeeded = succeeded + 1 | ||
echo result | ||
} | ||
|
||
echo "Ran command on successfully on {succeeded}/{attempted} targets" |