LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-12-2003, 07:22 PM   #1
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
A bash script question


I will pipe compressed archives to the standard input of a bash script.
How can I determine in the same script the name (or rather the extension) of the file that has been piped to the script?

My aim is as follows:
1. Pipe compressed files to the script
2. Which should call the appropriate de-compression utility to list the contents (filenames) in the archive
3. It should then return a specific exit code if the archive contained a windows executable
 
Old 05-12-2003, 09:01 PM   #2
AltF4
Member
 
Registered: Sep 2002
Location: .at
Distribution: SuSE, Knoppix
Posts: 532

Rep: Reputation: 31
standard input does not have a filename (unless you pass it as a parameter to the script)

you can try to guess the file type by using the "file" utility (which uses /etc/magic to determine the file type from the file header)
 
Old 05-13-2003, 02:13 AM   #3
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
Well, my script will be specified an external scanner module called by a mail sanitizer in the case of compressed mail attachments.

So far I thought that the mail sanitizer passes the attachments to the standard input of such external scanner modules.

Now I rather think it saves the attachments to a temporary location and only passes the filename to the external modules.

If it is so, it is better, since I can then obtain the filename in $1, besides, e.g. unzip did not seem very eager to accept data to be uncompressed on its standard input...
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH script question drj000 Programming 11 03-07-2005 10:25 PM
Bash script question deiussum Programming 6 08-14-2004 11:43 AM
bash script question djgerbavore Linux - Newbie 3 07-08-2004 03:39 PM
bash script question xscousr Programming 5 07-03-2003 05:04 PM
Bash script question J_Szucs Linux - General 4 05-29-2003 08:48 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:10 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