5 ms·
Show HN: New unix utility "when"
- apgwoz 13y agoI've so far only tested this on OS X, and have mostly used it with the `-t` mode to have it notify me (via "say") when ssh succeeds on a CloudFormation spawned AWS instance.
- apetresc 13y agoI went to go add a Homebrew formula for the name 'when', but it seems to be taken by this command-line calendar app: http://www.lightandmatter.com/when/when.html http://www.lightandmatter.com/when/when.html
- apgwoz 13y agoI struggled with a name. This morning in the shower, I liked "trip" but, I'm not sure I'll change it--certainly not because of homebrew.
- chingjun 13y agoWhat is the difference between this and 'while true; do cmd1 && cmd2; sleep 1; done'
- mooism2 13y agoIt looks to me more like until cmd1 ; do sleep 1 ; done ; cmd2
- d_theorist 13y agoYeah. I was thinking this.
- mphillips34 13y agowatch -n 1 foo && echo "why does this exist?"
- apgwoz 13y agoYes. See the -t flag. That's the reason I wrote it.
- lipanski 13y agoWhat's the difference between this and the bash '&&' operator? Except for the timebomb flag, I don't really see any difference. Please correct me if I got this wrong. The '&&' operator, as in which ruby && echo 'found it!', triggers the second command, if the exit code of the first one is 0. Also good to note, the '||' operator triggers the second command only if the exit code of the first one is different than 0. As in which ruby123456 || echo 'could not find it!'. EDIT: typo.
- bichiliad 13y agoIt looks like if the first parameter fails, then it is re-run until it succeeds.
- laumars 13y agoThis could be quite handy as need to do this sort of thing surprisingly often and usually resort to a shell script one-liner like this: while true; do echo "hello world"; sleep 3; done While that above code is pretty trivial to type, having a utility to this would be a great time saver for the lazy sysadmin :) edit: someone else just posted about watch[1], never knew that existed before today. You learn something new every day :D [1] https://news.ycombinator.com/item?id=6888640 https://news.ycombinator.com/item?id=6888640