[blfs-dev] bash script

Christopher Gregory me at pc-networking-services.com
Mon Jun 2 16:07:24 PDT 2014


On Tue, June 3, 2014 4:25 am, Aleksandar Kuktin wrote:
>> On Mon, 2 Jun 2014 23:57:40 +1200
>> "Christopher Gregory" <me at pc-networking-services.com> wrote:
>>
>
>> The script at:
>>
>>
>> http://lists.linuxfromscratch.org/pipermail/alfs-discuss/2005-December/
>> 007441.html
>>
>>
>> which has a few more features than the one on Bruce's SBU page:
>>
>> http://www.linuxfromscratch.org/~bdubbs/about.html
>>
>>
>> is what I am using, with the program name modified accordingly.
>
>> There has to be a way to just pass the integer value of Elapsed Time
>> to a variable without getting the frigging error that it is not an
>> integer value.
>
> See below for one approach.
>
>
>> I know from the research that time outputs to stderr.
>>
>
> This complicates matters somewhat. To say the least..
>
>
> # ...
>
>
> {
> # ... yada yada yada ...
> } 2>&1 | tee $SDIR/logs/$PROGRAM.log
> time_elapsed=$(grep 'Elapsed Time' $SDIR/logs/$PROGRAM.log | \ sed
> 's/^\([[:digit:]]\+\)\..*$/\1/');
>
>
> # ...
> echo "SBU: $(($time_elapsed / $standard_sbu))"
>
> Now, I tried for an hour or two to figure out a way that would redirect
> various outputs and inputs via anonymous pipes and produce both the effect
> of filling $time_elapsed and also print out the output on the screen. I
> failed. Which was really dissapointing because I think that a system like
> Linux should be able to do that. But no matter, the
> infomation we need is inside the log file, so you just make a second pass
> over the log file when all is done and extract the result.
>
> Maybe perl or tlc would be able to do this task better. The fact that
> the shell is unable to do what it SHOULD be able to do is quite embarrasing
> indeed.
>
> --
> Svi moji e-mailovi su kriptografski potpisani. Proverite ih.
> All of my e-mails are cryptographically signed. Verify them.
> --
> You don't need an AI for a robot uprising.
> Humans will do just fine.
> --
> http://lists.linuxfromscratch.org/listinfo/blfs-dev
> FAQ: http://www.linuxfromscratch.org/blfs/faq.html
> Unsubscribe: See the above information page
>
>

Hello,

Thanks for this.  It adds to my script collection nicely.

In the examples I was trying unsuccessfully to modify, they had the time
wrapped in multiple ((( and it just did not work.

Also from the research I discovered that the bash inbuilt time function
has a more limited amount of functionality than the gnu time.  Though from
looking we do not seem to install any other version of time.  It is listed
as released in 1996 on the gnu time website.

I am sorry that you spent so long in trying to get it to work correctly
via the anonymous pipes.

I was just going around in circles trying various things.

Regards,

Christopher.




More information about the blfs-dev mailing list