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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to clear the content of a pipe (STDIN) after it is written to another program? vvaidyan High Level Programming 10 05-15-2008 04:08 PM
AIX 5.3 - There is no process to read data written to a pipe vigsgb UNIX for Advanced & Expert Users 4 06-21-2006 01:09 AM
Clean file in single action djp Shell Programming and Scripting 1 06-19-2006 02:34 PM
Checking a file is not being written to kanejm Shell Programming and Scripting 14 01-20-2006 04:29 AM
File being used/written sanjay92 UNIX for Dummies Questions & Answers 4 10-13-2001 10:31 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-08-2008
Registered User
 

Join Date: Mar 2007
Posts: 84
Perform action file name written to the pipe

Hello,

I have a script that monitors files uploaded via ftp. After a successful upload, the file name is written to the pipe.

There is another program that reads this pipe and allows automatically run any program or script ( say test.sh ) to process the newly uploaded file.


cat test.sh
#############
mail -s mail -s "New upload : $1" test@test.tld


will email the filename to external email address.




now in test.sh I want to perform multiple functions:

1) email the uploaded file name ( which is done above )

2) grep/awk etc, for a string or word in the uploaded file and then

if

the exact word or string is found

then

do

grep -nr "$pattern" $1
echo " Following pattern found in file" $1 at line number >> /root/upload.log
/bin/rm -fr $1

else
echo "File safe: " $1 >> /root/upload.log



Now the pattern or word can be anyone of the following:

porn viagara cannibal maneater herbivore verygood millioniare donkey


so pattern is something like


pattern='porn|viagara|cannibal|maneater|herbivore|verygood|millioniare|donkey'





Please advise.


Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-09-2008
Registered User
 

Join Date: Mar 2008
Posts: 13
say something like this?

#!/bin/sh
pattern= word|word|word|word(Put your pattern here or read it from a file)

while :
do

case $pattern in

$pattern) rm -rf $1
*) echo "File Safe:$1 "
$1 >>/root/upload.log
esac

done
Reply With Quote
  #3 (permalink)  
Old 07-23-2008
Registered User
 

Join Date: Mar 2007
Posts: 84
yes, thanks the idea is right, I will verify and will udpate you soon
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:56 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0