Comments (4)
Hi!
This method isn't working for me:
sake exec -s server -o table $'uname -r | awk -v FS=\'-\' \'{print $1}\''
TASKS ***************************************************************************************************
host | task-0
------------+---------------------------------------------------------------
x.x.x.x | awk: cmd. line:1: {print
| awk: cmd. line:1: ^ unexpected newline or end of string
|
| Process exited with status 1
RECAP ***************************************************************************************************
x.x.x.x ok=0 unreachable=0 ignored=0 failed=1 skipped=0
The only way I could make it work was:
sake exec -s server $'uname -r | awk -v FS=\'-\' "{print $ 1}"'
That is, using doble quote for print and with a space between $ and number.
When defined as a task, it runs correctly when using:
print-kernel:
name: Kernel
desc: Print kernel version
spec: info
target: all
cmd: uname -r | awk -v FS='-' "{print $ 1}"
Thank you very much for your help!
from sake.
Double quotes work for me.
~ $ sake exec -s log "uname -r|awk -v FS='-' '{print $1}'"
TASK [task-0] ************************************************************
192.168.1.203 | 5.15.76-v8+
RECAP ********************************************************************
192.168.1.203 ok=1 unreachable=0 ignored=0 failed=0 skipped=0
from sake.
Hi:
Thanks for your quick response.
For me, it keep failing:
$:~# sake exec -s server "uname -r|awk -v FS='-' '{print $1}'"
TASK [task-0] ******************************************************************************************************************************
x.x.x.x | awk: cmd. line:1: {print
x.x.x.x | awk: cmd. line:1: ^ unexpected newline or end of string
x.x.x.x | Process exited with status 1
RECAP **************************************************************************************************************************************
x.x.x.x ok=0 unreachable=0 ignored=0 failed=1 skipped=0
I'm using Ubuntu 20.04, go 1.9 and latest version of sake.
For you, I think it doesn't work either. The output of your command must be 5.15.76, not 5.15.76-v8+. The awk part isn't working.
Best regards
from sake.
You're correct, this seems to work correct:
sake exec -s log -o table $'uname -r | awk -v FS=\'-\' \'{print $1}\''
TASK [task-0] ***********************************************************
192.168.1.203 | 5.15.76
RECAP *******************************************************************
192.168.1.203 ok=1 unreachable=0 ignored=0 failed=0 skipped=0
Use $'my \'string\''
to escape characters
- https://wiki.bash-hackers.org/scripting/bashchanges#quoting_expansions_substitutions_and_related
- https://stackoverflow.com/a/16605140/1645369
from sake.
Related Issues (20)
- Improve Tasks HOT 4
- Allow multiple servers with the same host name HOT 2
- Same host different port HOT 2
- Should fail on non-zero exit HOT 11
- Configuration handling HOT 2
- Too many authentication failures when defining lots of servers HOT 2
- How do you pronounce sake? HOT 3
- How can a task pass a value to next task HOT 4
- error: strconv.ParseInt: parsing "": invalid syntax HOT 7
- Option to disable "Running" output HOT 1
- Sake vs Ansible? HOT 4
- Port out of range error when used in host string HOT 2
- Outdated docs and NPE when formatting table headers HOT 2
- Can't access libvirt hosts via dns name HOT 11
- Is there a way to specify an alternative user for ssh via flag? HOT 2
- Workdir for remote is being used by `local: true` task HOT 1
- ssh: handshake failed HOT 7
- Distinguish servers by server-name, port and user in output HOT 3
- Multiple bastions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sake.