Bash script help (because I suck at it)
-
@Gąska said in Bash script help (because I suck at it):
You know that side project don't have to follow your company's processes?
Yes.
Is that question relevant to something we're discussing somehow?
-
@blakeyrat said in Bash script help (because I suck at it):
@Captain It would take more than a few work weeks to just begin designing the UI.
Sure if I wanted to make it really shitty and awful, I could probably shit-out something very quickly.In other words, you'd need to pay for a part time tester, and a design manager, and deck out a UX testing lab and hire a usability guidance counsel and user feels advocate and an ivory tower maintenance contractor...
-
@cartman82 I could do the testing myself, but it'd take a couple weeks to even create the mock-ups to test.
-
@cartman82 It's just typing. It's not that hard. At least not if you know your tools.
A more serious point: perfect is the enemy of good.
-
@blakeyrat said in Bash script help (because I suck at it):
@cartman82 I could do the testing myself, but it'd take a couple weeks to even create the mock-ups to test.
Do you have a more-or-less-complete idea how the UI should look like in your head? Yes? Then make a fucking prototype. It takes like an hour to have anything working in WPF or whatever. And what you need at this stage is anything working. And if you don't have the idea, then this is your problem, not lack of time or money.
-
@Gąska I now regret even sharing the idea.
-
@blakeyrat said in Bash script help (because I suck at it):
@Gąska I now regret even sharing the idea.
Every time you post a let's play now, we'll be mentally calculating how many usability tests could you have done instead for your upcoming AWK product.
-
@cartman82 I don't give a shit what you do, as long as you don't harass me about it.
-
@blakeyrat said in Bash script help (because I suck at it):
@cartman82 I don't give a shit what you do, as long as you don't harass me about it.
Your upcoming awk tool could filter out all the harassing messages in a few simple clicks. Just saying.
-
@Captain said in Bash script help (because I suck at it):
perfect is the enemy of good.
@blakeyrat is the enemy of good. (That can be interpreted several was; not all interpretations are equally valid.) But sometimes "good enough" really is good enough; for raisins I can't grasp, Blakey is philosophically unable to accept this.
-
@HardwareGeek said in Bash script help (because I suck at it):
But sometimes "good enough" really is good enough; for raisins I can't grasp, Blakey is philosophically unable to accept this.
It took me a long time to learn that myself. Perfectionism is a barrier to getting shit done.
-
@blakeyrat said in Bash script help (because I suck at it):
@cartman82 I don't give a shit what you do, as long as you don't harass me about it.
What counts as harrasment for you? Does saying that your excuses are bullshit count?
-
@asdf said in Bash script help (because I suck at it):
Perfectionism is a barrier to getting shit done.
-
@blakeyrat said in Bash script help (because I suck at it):
@Onyx I think you guys are really underestimating how long quality software works.
Or we have a different definition of "quality" — one that is achievable by actual humans and acknowledges that it is often necessary to sacrifice perfection (which is unachievable, anyway) in order to achieve other worthwhile goals, like actually delivering a product before the heat death of the universe.
-
@asdf said in Bash script help (because I suck at it):
@HardwareGeek said in Bash script help (because I suck at it):
But sometimes "good enough" really is good enough; for raisins I can't grasp, Blakey is philosophically unable to accept this.
It took me a long time to learn that myself. Perfectionism is a barrier to getting shit done.
Maybe that's why I never get shit done.
Filed under: No, it's certainly not because of this website...
-
@dkf said in Bash script help (because I suck at it):
@asdf said in Bash script help (because I suck at it):
Perfectionism is a barrier to getting shit done.
I counter your Rosie with another Rosie.
-
@blakeyrat Well, you just mentioned CSVs processing and awk, I assumed you were just talking about simple transformations from one file format to another. This doesn't imply something outside a small utility that reads a file, gives you a way to define a few rules and writes a file.
So yes, for a first iteration of something within that scope "a few weeks" sounds like a reasonable estimate to me. If the scope of the project is much larger than that then fair enough, but in that case "graphical awk" is too loose of a description.
-
@flabdablet said in Bash script help (because I suck at it):
@JazzyJosh meh.
#!/bin/bash mintime=3600 awk ' /^[^ ]/{ queue = $1 } /last was /{ sub(/^ */, "") sub(/ .*last was /, "\t") sub(/ .*$/, "\t" queue) print }' | while read member time queue do if ((time > mintime)) then echo "$time > $mintime for member $member in queue $queue" fi done
I understand that was just a quick example, but couldn't you substitute
#!/bin/bash
for#!/bin/awk -f
and add the rest of the logic to the AWK script itself?mintime
should be available via ARGV and AWK has if-statement support. It can run external command too.
-
@Onyx now it's more likely to be installed than even Perl.
-
@wft the machine(s) are not under my control and I'm in complete CYA mode when it comes to this particular client, so.
I'm probably overly paranoid but some of the shit we had happening with this client...
-
@Onyx Can you find out what Linux they're using? If it's Debian-based, like Ubuntu or Mint, it has to have Perl.
-
@Onyx said in Bash script help (because I suck at it):
The modification, BTW, was capturing that as well, the if should be, in pseudo code, if time < constant and state != "In use" (time updates after a call ends, and if it's longer than constant it might log the agent out when not necessary).
#!/bin/bash constant=3600 #or whatever while IFS= read line do set -- $line case "$line" in *'(In use)'*) ;; *'(last was '*) member=$1 line=${line##*last was } time=${line%% *} if ((time < constant)) then echo "$time < $constant and not (In use) for member $member in queue $queue" fi ;; ' '*) ;; *) queue=$1 ;; esac done
Edit: if the condition
state == "(Not in use)"
is acceptable instead ofstate != "(In use)"
then you could combine the first two case conditions:case "$line" in *'(Not in use)'*'(last was '*)
Edit: because the only field made available by
set -- $line
that actually gets used is$1
, it might be better to avoid worrying about glob risks and breaking that field out by hand instead:#!/bin/bash constant=3600 #or whatever while IFS= read line do case "$line" in *'(Not in use)'*'(last was '*) read member rest <<<"$line" read time rest <<<"${rest##*(last was }" if ((time < constant)) then echo "(Not in use) and $time < $constant for member $member in queue $queue" fi ;; ' '*) ;; *) read queue rest <<<"$line" ;; esac done
-
@flabdablet said in Bash script help (because I suck at it):
@JazzyJosh meh.
#!/bin/bash mintime=3600 awk ' /^[^ ]/{ queue = $1 } /last was /{ sub(/^ */, "") sub(/ .*last was /, "\t") sub(/ .*$/, "\t" queue) print }' | while read member time queue do if ((time > mintime)) then echo "$time > $mintime for member $member in queue $queue" fi done
@Onyx: Once you understand that awk is essentially a fancier sed, and like sed processes input a line at a time, the only non-obvious thing about the awk script above is the way awk breaks input lines into fields. Fields are a special kind of variable in awk, and they have names that start with $; other variables have plain words for names. When awk reads a line, it goes in field $0 (which is also the default target for the sub and print functions, much like $_ in perl). Fields $1, $2, $3... get implicitly filled in by splitting $0 on whitespace (which is why the awk version of this logic doesn't need to do line editing to isolate the queue name).
I'd go for a pure awk solution:
#!/usr/bin/awk -f BEGIN { mintime=3600 } /^[^ ]/ { queue=$1 } /last was/ { if( 0 < match( $0, /last was ([0-9]+) secs ago/, a ) && (a[1] > mintime) ) { printf( "%s has not taken calls in %d seconds (>%d)\n", $1, a[1], mintime ); } }
Might need another flag set if the 'Callers' lines (not shown) can match the
last was ... secs ago
regex.In this case, column stuff is not useful as I don't see an effective way to split into positional columns, even though awk allows using a regex to split in columns.
-
@PleegWat said in Bash script help (because I suck at it):
printf( "%s has not taken calls in %d seconds (>%d)\n", $1, a[1], mintime );
should be
printf( "%s has not taken calls in %d seconds (>%d)\n", queue, a[1], mintime )
Also, awk is not a semicolons language. You can use them to put more than one statement on a line, but other than that there's no need for them.