Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Recently, I tried connecting to my GeeXbox via WinSCP but got an error indicating the output of ls could not be parsed.

Apparently, my ls does not include a time stamp! What might be the cause and how can I correct that? See a sample output below:

$ ls -la
total 96
drwxrwxr-x   17 root     root          4096 .
drwxrwxr-x   17 root     root          4096 ..
lrwxrwxrwx    1 root     root             7 bin -> usr/bin
-rw-rw-r--    1 root     root         39779 config
drwxr-xr-x   13 root     root          3980 dev
drwxrwxr-x   29 root     root          4096 etc

My particular ls --help offers this:

$ ls --help
BusyBox v1.23.0.git (2014-05-19 13:33:13 IDT) multi-call binary.

Usage: ls [-1AaCxdlinshrSXv] [-w WIDTH] [FILE]...

List directory contents

    -1      One column output
    -a      Include entries which start with .
    -A      Like -a, but exclude . and ..
    -C      List by columns
    -x      List by lines
    -d      List directory entries instead of contents
    -l      Long listing format
    -i      List inode numbers
    -n      List numeric UIDs and GIDs instead of names
    -s      List allocated blocks
    -h      List sizes in human readable format (1K 243M 2G)
    -r      Sort in reverse order
    -S      Sort by size
    -X      Sort by extension
    -v      Sort by version
    -w N    Assume the terminal is N columns wide
    --color[={always,never,auto}]   Control coloring
share|improve this question
    
And that's, dear children, why you're not supposed to parse the output of ls, different implementations, different output. Does ls --help give you an option to add the timestamp to the output? –  Bobby May 24 at 10:02
    
@Bobby: see my edit –  Arne May 24 at 10:06
    
It may have something to do with terminal width or tabstops. You might want to try the -w option. The reason you get the complaint is your Busybox is not POSIX compliant. The output of ls -l is POSIX specified to be "%s %u %s %s %u %s %s\n", <file mode>, <number of links>, <owner name>, <group name>, <number of bytes in the file>, <date and time>, <pathname> You can look at busybox.net/BusyBox.html which says busybox ls should also have a -e for full date and time., –  mikeserv May 24 at 10:33

1 Answer 1

Often times systems that are a "dedicated appliance" will make use of a tool called BusyBox. You can read more about the BusyBox project, but in a nutshell this project provides stripped down versions of typical tools such as ls, etc.

On my installations of XBMC that also use BusyBox the version of ls does show the the timestamp info when I do an ls -l. There's also an additional switch -e which will produce time date info.

# ls --help
BusyBox v1.21.0 (2013-01-22 19:16:54 CET) multi-call binary.

Usage: ls [-1AaCxdLHRFplinsehrSXvctu] [-w WIDTH] [FILE]...

List directory contents

    -1  One column output
    -a  Include entries which start with .
    -A  Like -a, but exclude . and ..
    -C  List by columns
    -x  List by lines
    -d  List directory entries instead of contents
    -L  Follow symlinks
    -H  Follow symlinks on command line
    -R  Recurse
    -p  Append / to dir entries
    -F  Append indicator (one of */=@|) to entries
    -l  Long listing format
    -i  List inode numbers
    -n  List numeric UIDs and GIDs instead of names
    -s  List allocated blocks
    -e  List full date and time
    -h  List sizes in human readable format (1K 243M 2G)
    -r  Sort in reverse order
    -S  Sort by size
    -X  Sort by extension
    -v  Sort by version
    -c  With -l: sort by ctime
    -t  With -l: sort by mtime
    -u  With -l: sort by atime
    -w N    Assume the terminal is N columns wide
    --color[={always,never,auto}]   Control coloring

So I would assume that you're encountering 1 of 2 situations.

  1. Your version of BusyBox doesn't include timestamps in the -l output. I doubt this is the case, BTW.
  2. The filesystem has timestamp tracking disabled via a mount option, due to the overhead involved with having to track this info.

There are options such as noatime which will disable the tracking of access time on the file system, for example.

$ mount -v
/dev/mmcblk0p1 on /flash type vfat (ro,noatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
share|improve this answer
    
I think it's problem #1. Look at his --help - there's no sort by ?time of any kind. What utility checks mount options before offering --help ? –  mikeserv May 25 at 2:40
    
@mikeserv - With #1 I just think it's highly unusual that a version of BusyBox would omit the timestamp. Just my $0.02 on that one 8-). No tool I'm aware of would look at mounts options, per say, but the tools might know how to deal with data that isn't present in the output. stat would likely be doing the same thing here. –  slm May 25 at 4:45
    
Totally agreed - completely unusual. That's why WinSCP is able to rely on parsing that data. Somebody just built Busybox all crazy. –  mikeserv May 25 at 4:49
    
Sorry man. I forgot to do that before. –  mikeserv May 26 at 19:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.