There are a lot of different file formats and many of them are the same
on all platforms.  For example, as fas as I know the format for JPEG
files is platform independent.  What sorts of files are you interested
in?   And on what platform(s) will you want to run the script? 

On unix systems, for example, the file type (and hence it's format) is
encoded in the first two bytes of the file which are known as the "magic
number".  The file command is used to look up the magic number and print
out the file type based information in the magic file that is commonly
installed at /etc/magic or /usr/share/magic/.  The file command can do
some other tests some of which are built-in and some of which can be
specified in the magic file - see
http://docs.sun.com/db/doc/816-0210/6m6nb7m9e?a=view and
http://unixhelp.ed.ac.uk/CGI/man-cgi?file. 

The file command could be done in perl, or you could remotely mount
shares from the other systems of interest on a unix system and use its
file command.  There are some good clues to doing most of it in perl at
http://www.kfunigraz.ac.at/edvndwww/books/books/perl2/sysadmin/ch02_04.h
tm.  (The clues are to use Win32::File::GetAttributes() in WinNT/2K with
NTFS/FAT file systems and to use MacPerl::GetFileInfo() in MacOS with
HFS file systems and system("file filename\n") on Unix systems.)

When you've finished the Universal File Type Detector be sure to let us
know! :)

-tristram



-----Original Message-----
From: Mohamed HOUSSNI [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 01, 2003 12:26 PM
To: [EMAIL PROTECTED]
Subject: script+file format


Hello,

I am looking for a perl script to detect and display a format of file 
(i.e. unix, dos or mac).

I will be very grateful to you to help doing this.

Best regards,

-- 
Dr. Mohamed Houssni




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to