How to redirect stdout to one pipe and stderr to another in bash or bourne shell

Posted on August 11th, 2017 by whinger. Filed under Tech.


So I couldn’t find an answer to this when I searched for it… how can I redirect stdout to one pipe and stderr to another?

In my head, it seems like you should be able to do

mycommand |stdoutpipecmd 2|stderrpipecmd

but you can’t.

There are many answers knocking around stackexchange that seem to not-quite do what I wanted, plus in bash you can apparently do command-redirection with 2>(stderrpipecmd); however I was using bourne shell (embedded system) so that didn’t help me.

 

Of course the answer is really ridiculously simple: simply encapsulate the redirect into a subshell, and redirect the stderr of the subshell into stdout and pipe that.

So

( mycommand | stdoutpipecmd ) 2>&1 | stderrpipecmd

It’s really that simple.

 

If you want to make the result of stdoutpipecmd not be piped through stderrpipecmd (you probably don’t), you can do

 

( mycommand | stdoutpipecmd 1>&3 ) 3>&2 2>&1 | stderrpipecmd

which will pipe the output from stdoutpipecmd to stderr, while the output from stderrpipecmd will be on stdout.

To fix that, so the output from stdoutpipecmd ends up back on stdout while the output from stderrpipecmd is on stderr, it gets a bit messier:

( ( mycommand | stdoutpipecmd 1>&3 ) 2>&1 | stderrpipecmd ) 3>&1 1>&2

What fun 🙂

Tags: , , , .



Fritz!Box remote SIP with different auth username

Posted on June 15th, 2016 by whinger. Filed under Uncategorized.


So I was given “username” and “auth username” parameters for my SIP trunking account, and it’s non-obvious where those values go in the fritz UI.

The answer, to save you the trouble of faffing with various possible options, is that the “username” goes in the “*Telephone Number for Registration” field at the top, while the auth username goes in the “Account Information” “User name” field. Make sure you check the “Use Internet telephone number for registration” checkbox too.

.



Merge non-adjacent partitions in Windows

Posted on October 30th, 2015 by whinger. Filed under Tech.


So I got a new-to-me laptop with UEFI and Dell’s fingerprints are all over the partitions. Two partitions C: and D:, 500GB each (just about), which irritates the hell out of me, there’s almost never any good reason to want to split your disk usage in that way.

So I went into disk management to merge the two partitions and found a Dell Recovery partition in the way. Being a UEFI laptop it’s pretty clear from the internet that you can’t just delete these “recovery” partitions because the machine may well fail to boot afterwards, so I thought I was stuffed; happily there’s a nice free little program that will do exactly what’s required with the minimum of fuss.

AOMEI Partition Assistant

Deleted the D partition, moved the offending recovery partition to nearly at the end of the blank space, created a non-mapped partition in the remaining 20MB (just in case the system expects that partition to still exist), click “apply” and watch as it does its magic. Very happy 🙂

 

Usual disclaimer – I’ve never even heard of them before, so I’ve definitely no link to anyone involved.

.



The worst bargain ever?

Posted on November 18th, 2012 by whinger. Filed under Uncategorized.


Just took out the cauliflower that Asda’s home delivery gave us this week. All good, until I removed the leaves:

Picture of tiny cauliflower with huge leaves

That’s just taking the piss.

.



Fix Vista “Calculating time remaining” on flash drive

Posted on February 25th, 2012 by whinger. Filed under Tech.


I’ve recently changed laptop to one with Vista64, which bothered me because I’ve stuck stubbornly with XP; however I’ve been impressed with the speed and usability of what is now a pretty stable OS.

One thing, though, that’s been really annoying me is that copying and deleting files on USB flash disks has suddenly added an extra layer of irritation: a “calculating time remaining” message that usually takes about 5 times as long as the actual operation. Quite how you can take 5 minutes to delete a file is beyond me.

The solution seems quite simple: change the settings for the flash drive from “optimize for quick removal” to “optimize for performance”. The problem simply goes away.

This is definitely a bug – the amount of time we’re talking about here is massive and isn’t explainable by write caching; however at least now I can cope. I just have to remember to click “remove” on the device before pulling the stick, but to be honest I always do that anyway.

.



It’s official: don’t believe anything you read about a product on ebay

Posted on August 3rd, 2011 by whinger. Filed under Uncategorized.


So I had an online chat with an ebay support representative about the fact that ebay’s “detailed item information” boxes, which are provided automatically by ebay, often actually contain incorrect information.

The response:
“we always advise buyers to contact the selelr (sic) directly if they have any clarification on the item listed”

Nice. So I’m supposed to assume that everything is untrue, and if I actually care about the thing that’s listed I should check with the seller, otherwise ebay will disclaim all responsibility.

As an aside, I also like the fact that if someone sells you something in auction, and it turns out not to be as described, ebay’s own recommendation is that you should cover the cost of returning the item.

.



What’s wrong with this picture?

Posted on June 19th, 2011 by whinger. Filed under Uncategorized.


Asda says 400g for 58p is £2.42 per kilo

Asda's website shows us the true mathematical genius of cloud computing

.



not my usual type of blog post, but…

Posted on January 21st, 2011 by whinger. Filed under Uncategorized.


So I don’t usually post links to stuff like this, but if you haven’t seen Vivian Maier’s street photography, you really must.

.



android alarm fail

Posted on May 25th, 2010 by whinger. Filed under Tech.


Lesson number 36 of Android.

Want your android phone’s alarm to wake you in the morning? Don’t kill the “clock” process.

I thought that process was just the front-end bit. It seems not. Thank goodness Willow was there to remind me it was time for walkies…

Tags: .



ntp suxx0r, d00d5

Posted on May 9th, 2010 by whinger. Filed under Uncategorized.


This Dr Dobbs article caught my eye when I was looking for a Windows Mobile NTP client (long story). I read it with some alarm as the introduction implies that they’ve found a fundamental problem with NTP and then became steadily more incredulous as I read the article to find that they were talking about periodically running – on mission-critical systems, of course – ntpclient to synchronise with a single time source.

They’ve basically written up alarmist crap that’s worthy of the Daily Mail about the fact that if you use what’s essentially a test program against a single not-particularly-stable server it doesn’t work very well. Big surprise.

Does anyone really use ntpclient like that on a critical production server? I’d have thought configuring ntpd with a few ntp servers wasn’t exactly hard – there’s even a pretty noddy Redhat howto for it. And yet the title of the article (and especially the introduction) suggest that they’ve uncovered a fundamental problem with ntp.

I’m left wondering if timekeeper is a Dr Dobbs product, to be honest.

.



Blogroll

Categories