mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-24 23:10:41 +02:00
docs(weed-shell): add scripting section with heredoc, piping, and -debug flag
1 parent
553804fe60
commit
4d74795dd2
1 file changed
+24
+24
@@ -308,6 +308,30 @@ Use `-expiry` for time-limited credentials (must be positive; 0 = no expiration)
|
||||
`s3.iam.export -file` writes with mode 0600 to protect credentials.
|
||||
`s3.iam.import` requires `-apply` since it overwrites the entire IAM configuration.
|
||||
|
||||
# Scripting with weed shell
|
||||
|
||||
When stdin or stdout is piped, `weed shell` automatically suppresses the `> ` prompt and informational logs, making it easy to use in scripts and parse output with tools like `jq`.
|
||||
|
||||
### Heredoc for multiline commands
|
||||
```bash
|
||||
weed shell << EOF
|
||||
lock
|
||||
volume.fix.replication -n
|
||||
unlock
|
||||
EOF
|
||||
```
|
||||
|
||||
### Pipe JSON output to jq
|
||||
```bash
|
||||
echo "s3.user.list" | weed shell | jq '.[] | select(.keys > 0)'
|
||||
```
|
||||
|
||||
### Debug mode
|
||||
Use `-debug` to re-enable informational logs on stderr:
|
||||
```bash
|
||||
echo "s3.user.list" | weed shell -debug 2>shell.log | jq
|
||||
```
|
||||
|
||||
# One more trick
|
||||
You can skip the "fs." prefix, for all "fs.*" commands:
|
||||
```
|
||||
|
||||
Reference in new issue
Block a user