Ralf.Strandell@silja.com
2001-Dec-20 03:47 UTC
File mode badly shown in smbclient (want DAHR,---R,---- etc)
Hi We are using smbclient to automatically (& remotely) monitor the sizes and ages of files. The file names contain spaces of course. Some files have attributes set. Now how do I separate between file attributes and the file name in the following directory listing? EXAMPLE: smb: ?> dir *file* second file is called AR 0 Fri Sep 15 12:37:54 2000 file name with spaces AR 0 Fri Sep 15 12:37:54 2000 QUESTION: does the AR belong to the filename of "second file is called AR" or does it say that the attributes of "second file is called" are "AR"? For me it's obvious, but for my scripts it isn't. FIX: Smbclient should use this notation: DAHR or -A-R for attributes. Could somebody please include this in a future version of Smbclient. ==========================Ralf Strandell UNIX System Administrator Silja Line, Finland ===========================
David Collier-Brown
2001-Dec-20 05:31 UTC
File mode badly shown in smbclient (want DAHR,---R,---- etc)
Ralf.Strandell@silja.com wrote:> > Hi > > We are using smbclient to automatically (& remotely) monitor the sizes and > ages of files. The file names contain spaces of course. Some files have > attributes set. Now how do I separate between file attributes and the file > name in the following directory listing? > > EXAMPLE: > > smb: ?> dir *file* > second file is called AR 0 Fri Sep 15 12:37:54 2000 > file name with spaces AR 0 Fri Sep 15 12:37:54 2000This is easy: cut -c 1-33 $$ >$$.name cut -c 34-37 $$ >$$.attr cut -c 38-46 $$ >$$.size cut -c 47- $$ >$$.date paste -d: $$.name $$.attr $$.size $$.date rm $$ On the other hand, an option to ls to make it use a unix-like notation might make good sense. -l, perhaps (:-)) --dave -- David Collier-Brown, | Always do right. This will gratify Americas Customer Engineering, | some people and astonish the rest. SunPS Integration Services. | -- Mark Twain (905) 415-2849 | davecb@canada.sun.com
Joel Hammer
2001-Dec-20 05:51 UTC
File mode badly shown in smbclient (want DAHR,---R,---- etc)
I am NOT a C programmer but: This is an easy thing to modify in the source code. There is a line in client.c (line 330 in 2.2.1a) like so: DEBUG(0,(" %-30s%7.7s %8.0f %s", Change it to read: DEBUG(0,(" <%-30s>%7.7s %8.0f %s", ^ ^ Recompile (I just have to run make, takes about 5 seconds) and then you get output like this: <initrd > D 0 Sat Jul 8 17:12:46 2000 The new version will be in source/bin. Don't run make install unless you want this to be the new, system wide version of smbclient. I was not able to use control characters in the DEBUG string, but, this sort of output should be easy enough to parse. It might be possible to embed special characters which wouldn't even be in a windows file name, but I just don't know how to do that. I am sure it would be possible to have confusing file names with < > in them, but, it should be possible to script around them. Or, make the separator as bizarre as you can eg. %^&$* or some silly thing. You could compile this special version of smblcient and use it only for your scripts, so regular users or other programs wouldn't be confused by it. If you want help devising a script to parse this, I am sure the sedophiliacs at: sed-users@yahoogroups.com would be glad to help. Joel On Thu, Dec 20, 2001 at 01:12:07PM +0200, Ralf.Strandell@silja.com wrote:> Hi > > We are using smbclient to automatically (& remotely) monitor the sizes and > ages of files. The file names contain spaces of course. Some files have > attributes set. Now how do I separate between file attributes and the file > name in the following directory listing? > > EXAMPLE: > > smb: ?> dir *file* > second file is called AR 0 Fri Sep 15 12:37:54 2000 > file name with spaces AR 0 Fri Sep 15 12:37:54 2000 > > QUESTION: > does the AR belong to the filename of "second file is called AR" > or does it say that the attributes of "second file is called" are > "AR"? > > For me it's obvious, but for my scripts it isn't. > > > FIX: Smbclient should use this notation: DAHR or -A-R for attributes. > Could somebody please include this in a future version of Smbclient. > > > ==========================> Ralf Strandell > UNIX System Administrator > Silja Line, Finland > ==========================> > -- > To unsubscribe from this list go to the following URL and read the > instructions: http://lists.samba.org/mailman/listinfo/samba
Joel Hammer
2001-Dec-21 06:34 UTC
File mode badly shown in smbclient (want DAHR,---R,---- etc)
I think you could just ship the smbclient program. Samba and smbclient are two distinct animals. Or, if you are more ambitious, and know more than me, you could ship a doctored version of smblient which would take an additional command line option that would use the different output string. If I have the time, likely I won't, I'll play with it. Joel On Fri, Dec 21, 2001 at 09:40:47AM +0200, Ralf.Strandell@silja.com wrote:> Thanks. > > However... > Unfortunately I cannot rely on non-standard versions of software. > My script will be distributed to a number of people with different versions > of Samba. > I could list the latest version of Samba in the requirements, but certainly > nothing like "recompile required". Thus the problem remains. > > ______________________________ > Ralf Strandell > UNIX Systems Administrator > Silja Line, Finland > ______________________________ > > > > -----Original Message----- > > From: Joel Hammer [mailto:jhammer2@home.com] > > Sent: 20. joulukuuta 2001 16:51 > > To: samba@lists.samba.org > > Subject: Re: File mode badly shown in smbclient (want DAHR,---R,---- > > etc) > > > > > > This is a new and improved version of that statement. > > This should be easy to parse, no matter what awful file name you have. > > DEBUG(0,(" <%s>(%s)|%.0f|%s", > > Gives this output: > > <junkbig.ps>()|31344767|Sat Dec 8 13:00:42 2001 > > <junkbig>()|31344767|Sat Dec 8 13:01:36 2001 > > <opera-6.0-20011129.1-static_qt.i386.tar.gz>()|4081948|Sun > > Dec 9 21:29:54 2001 > > <opera-6.0-20011129.1-static_qt.i386>(D)|0|Sun Dec 9 21:33:14 2001 > > <lib>(D)|0|Sun Dec 9 21:34:23 2001 > > > > This is the sed command (very messy) which parses this for you: > > #!/bin/bash > > sed "{ > > s/\( > > *<\)\(.*\)\(>\)\((\)\(.*\)\()\)\(|\)\(.*\)\(|\)\(.*\)$/\"\2\" > > \"\5\" \"\8\"/ > > }" > > It doesn't matter if there are embedded < or > in the file > > name. Sed goes > > to the last character it can fit into the seach string. > > > > This is the output: > > "junkbig.ps" "" "31344767" > > "junkbig" "" "31344767" > > "opera-6.0-20011129.1-static_qt.i386.tar.gz" "" "4081948" > > "opera-6.0-20011129.1-static_qt.i386" "D" "0" > > "lib" "D" "0" > > > > Ain't open source grand? > > Joel > > > > > > -- > > To unsubscribe from this list go to the following URL and read the > > instructions: http://lists.samba.org/mailman/listinfo/samba > >
Maybe Matching Threads
- problem with samba 3.0.28/Solaris 8/smbclient
- How to see loging of the user
- Problems with "Marco Polo Großer Reiseplaner 2005/2006" - Can't print/Street names not shown correctly/Route not shown
- problem in "depot" app - cart contents not shown on checkout
- Depreciated client still shown on OST exports