LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-12-2010, 08:31 AM   #1
shree24985
LQ Newbie
 
Registered: Jan 2009
Location: Mumbai
Distribution: slackware
Posts: 15

Rep: Reputation: 0
File type check in perl


Hi,
I am witing a file upload program in perl where i need to upload a wav or a gsm file and save it as a gsm file.

How can i make sure that the uploaded file is a wav or a gsm sound file and not an executable malicious script or something.
 
Old 10-12-2010, 09:47 AM   #2
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 542

Rep: Reputation: 79
I don't know in perl, but you can call the external program "file" and grab the output.

Here is an example of the output
Code:
$ file Roland-GR-1-Pick-Bass-2-C4.wav
Roland-GR-1-Pick-Bass-2-C4.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 44100 Hz
 
Old 10-12-2010, 12:41 PM   #3
shree24985
LQ Newbie
 
Registered: Jan 2009
Location: Mumbai
Distribution: slackware
Posts: 15

Original Poster
Rep: Reputation: 0
Thanks angel.
file program would also help me make out if its an executable.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Check file system type of a partition EmrldDrgn Linux - Newbie 3 07-11-2009 07:56 AM
perl- check size to see if file is complete michael.barnes Programming 2 02-13-2008 06:20 PM
Perl: Check if file has been created in the last 10 minutes introuble Programming 2 06-02-2006 10:58 AM
Perl: Check if "$str" is of type [A-Z]<char string>[0-9][0-9] introuble Programming 2 06-02-2006 10:33 AM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:15 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration