LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices

Reply
 
Search this Thread
Old 07-31-2010, 03:56 PM   #1
na5m
Member
 
Registered: Jan 2005
Location: california
Distribution: O.A.M. (Overmonitoring Address Matrix) Release 2.2 with 2120 Patch
Posts: 37

Rep: Reputation: 17
time command gives error for SBU in Binutils


Code:
$ time { ../binutils-2.20/configure --target=$LFS_TGT --prefix=/tools --disable-nls --disable-werror && make && make install; }
bash: syntax error near unexpected token `}'
$ time -V
GNU time 1.7
$ type time
time is /usr/bin/time
I'm reading LFS Stable 6.6. Maybe the time command
method in the Binutils section needs to be updated.
I'm using PCLinuxOS 2010.07.

After googling, I found that this works:
Code:
$ time bash -c " foo && bar && blah ; "
Any thoughts?
 
Old 07-31-2010, 04:53 PM   #2
carltm
Member
 
Registered: Jan 2007
Location: Canton, MI
Distribution: CentOS, SuSE, Red Hat, Debian, etc.
Posts: 697

Rep: Reputation: 93
The problem is not with time, it is bash that is sending the error.

My guess is that bash is expecting a command after the semicolon,
and is finding the "}" instead. Try removing the semicolon.

Last edited by carltm; 07-31-2010 at 04:55 PM.
 
Old 08-01-2010, 02:13 AM   #3
na5m
Member
 
Registered: Jan 2005
Location: california
Distribution: O.A.M. (Overmonitoring Address Matrix) Release 2.2 with 2120 Patch
Posts: 37

Original Poster
Rep: Reputation: 17
Without the trailing semicolon, I get this error:
Code:
$ time { command }
time: cannot run {: No such file or directory
So, it looks like with the semicolon, bash raises an error.
Without the semicolon, time raises an error.
 
Old 08-01-2010, 03:47 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

There are 2 versions of the time command and they work differently:

1) A bash internal, which is used in the LFS example ($ type time -> time is a shell keyword)
2) An external time command, which you seem to use ($ type time -> time is /usr/bin/time)

The order in which bash looks for them: first the internal command, if not present the external one.

I find it a bit curious that you do not have the internal bash time command. Looks like PCLinuxOS 2010.07 is different that way.

Did you check the vii. Host System Requirements and is PCLinuxOS 2010.07 compliant for building LFS?

Anyway, this does explain the discrepancy.

Hope this helps.

Last edited by druuna; 08-01-2010 at 03:49 AM.
 
Old 08-01-2010, 01:23 PM   #5
na5m
Member
 
Registered: Jan 2005
Location: california
Distribution: O.A.M. (Overmonitoring Address Matrix) Release 2.2 with 2120 Patch
Posts: 37

Original Poster
Rep: Reputation: 17
I've since discovered:
PCLinuxOS 2010.07 does meet the host system requirements.
However, the time command shown in the LFS book is the bash
builtin command, not /usr/bin/time.
So, if your bash doesn't have time built into it, then the SBU value's command will fail.
I think the book should be updated to warn users of this possibility.
I'm guessing that most distros have a bash with time built into it.
PCLinuxOS 2010.07 isn't one of them:
Code:
$ builtin time
bash: builtin: time: not a shell builtin
EDIT:
Things have changed: I downloaded and burned lfslivecd-x86-6.3-r2160.iso.
I booted into it and got:
Code:
# which time
which: no time in (/bin:/usr/bin:/sbin:/usr/sbin)
# builtin time
-bash: builtin: time: not a shell builtin
# type cd
cd is a shell builtin
# type time
time is a shell keyword
Talk about complicated and confusing!
So I guess that time can either be
  1. a system file
  2. a shell builtin
  3. a shell keyword

Last edited by na5m; 08-01-2010 at 02:31 PM. Reason: New discovery
 
Old 08-01-2010, 02:56 PM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

Quote:
So I guess that time can either be
a system file
a shell builtin
a shell keyword
Time is, when it comes down to it a builtin, but...... The time command is listed in the official Bash documentation as a keyword ("reserved word") and will show up as such.

The time command can be an executable (/usr/bin/time) and/or a bash keyword.

BTW: Time is one of the bash defaults, if you compile it normally it will be included. So I guess that PCLinuxOS should mention this (and other?) exclusion, it would be undoable for LFS to mention all the exceptions to the defaults other distro's created (be it for good or bad).

In general these external commands (time being one, pwd being another) are there for specific reasons. They work slightly different or have some other features. You also need to call them explicitly:
pwd for normal use (the bash keyword that is),
/bin/pwd to use the external executable.

Hope this helps.
 
1 members found this post helpful.
Old 08-01-2010, 05:55 PM   #7
na5m
Member
 
Registered: Jan 2005
Location: california
Distribution: O.A.M. (Overmonitoring Address Matrix) Release 2.2 with 2120 Patch
Posts: 37

Original Poster
Rep: Reputation: 17
Thank you, druuna. It's hard to imagine that time could be a keyword,
like while, for, do, etc. Anyway, I guess we've beat this dead horse
long enough

PS- this site spilled some light on the topic:
http://tldp.org/LDP/abs/html/internal.html
 
Old 08-01-2010, 07:23 PM   #8
carltm
Member
 
Registered: Jan 2007
Location: Canton, MI
Distribution: CentOS, SuSE, Red Hat, Debian, etc.
Posts: 697

Rep: Reputation: 93
Anyway, going back to the original problem:

Quote:
$ time { command }
time: cannot run {: No such file or directory
Try using parentheses instead of curly braces.
 
Old 08-01-2010, 10:17 PM   #9
na5m
Member
 
Registered: Jan 2005
Location: california
Distribution: O.A.M. (Overmonitoring Address Matrix) Release 2.2 with 2120 Patch
Posts: 37

Original Poster
Rep: Reputation: 17
Code:
$ /usr/bin/time ( ls )
bash: syntax error near unexpected token `ls'
 
Old 08-02-2010, 02:41 PM   #10
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
@carltm:
Quote:
Anyway, going back to the original problem:
Which problem

I though na5m already has a working solution: time bash -c " foo && bar && blah ; " (see post #1).
And I told why the two are different.
 
  


Reply

Tags
bash, binutils, lfs, near, time


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
nvidia display drivers installation error with binutils, binutils allready installed mandrakeBren Linux - Newbie 9 01-06-2009 12:52 PM
time command & 5.3.1. Installation of Binutils zuesko Linux From Scratch 11 04-30-2007 11:25 PM
Issue compiling binutils for the 2nd time crookt Linux From Scratch 2 03-26-2006 12:30 PM
Run Time Error- CLS command not found ashwinipahuja Programming 1 05-15-2004 12:50 AM
my sbu alaios Linux From Scratch 7 05-12-2004 08:04 AM


All times are GMT -5. The time now is 05:10 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration