The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Type I and Type II Errors - The Heart of Event Processing iBot Complex Event Processing RSS News 0 12-05-2007 06:50 PM
array type has incomplete element type jaganadh High Level Programming 1 07-24-2007 04:54 AM
Human readable type vs MIME type detection using file spauldingsmails Shell Programming and Scripting 0 03-22-2007 12:43 AM
Lynx - Downloading - extension handling - changing mime type? yitzle UNIX for Dummies Questions & Answers 2 10-18-2006 12:46 AM
How to Set Mime type to mailx suneel UNIX for Advanced & Expert Users 1 07-08-2003 12:17 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-02-2009
Rhije Rhije is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 103
Retrieving File's Mime-type

Alright, so I am trying to use perl (or any other shell scripting language, awk/sed/bash for instance), to retrieve the mime-type of a file.

I want to keep it in one file, and most of the modules that are on cpan that check for mime types (Magic), aren't installed on these boxes.

Anyone have a good way of checking for a file's mime type?
  #2 (permalink)  
Old 01-02-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,784
If you have the .pm file for mime type checking (for example like Lite.pm for mime::lite)
you do not necessarily have to "install" the module. Just put it in your directory on the machine you are using, say /home/Rhije/Lite.pm

and add this to the shebang in the top of your own perl code

Code:
#!/bin/perl -I/home/Rhije/Lite.pm

This may not always work, but mime content-type checking is reasonably complex, so it is definitely worth a try. Rather than rolling your own. You can pack the two files in a tarball, extract them and run the perl. I know it violates your "one file" request.
  #3 (permalink)  
Old 01-02-2009
Rhije Rhije is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 103
Sorry, not sure if I called it the correct thing. I meant the content type, such as image/*

I am trying to find what type of file it is, image, video, script, etc..
Closed Thread

Bookmarks

Tags
linux, mime type, perl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:27 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0