Linux Script to move executable to quarantine


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Linux Script to move executable to quarantine
# 1  
Old 05-12-2009
Question Linux Script to move executable to quarantine

Please help! I am preparing a Linux Script to move windows executable files from samba directory to quarantine directory. For safety, will use "file" command to determine if its executable. Anyone can help? Below is my trial script, but it just move everything, including non-executable.. any wrong with this?

cd path_of_samba_directory
for i in 'file -ib * | grep x-dosexec'; do
mv $i /tmp;
done
# 2  
Old 05-12-2009
You need to do a bit more than that:
Code:
SAMBAPATH=/export/samba/quarantine
LIST=`ls $SAMBAPATH`
LOOKFOR="x-dosexec"
for i in $LIST; do
        if (file -ib $i | grep $LOOKFOR > /dev/null 2>&1>/dev/null); then
                echo $i has it
        fi
done

or something like that.
# 3  
Old 05-12-2009
Bug

Thanks kodak. I finally get it done with this! a bit revision to get it automatically move executable to quarantine directory. And interestingly, a exe file is FOUND not an executable!! but its all fine. Smilie

Code:
#!/bin/bash
SAMBAPATH=/exports/samba
LIST=`ls $SAMBAPATH`
LOOKFOR="x-dosexec"
EXE=/tmp/exelist.log

cd $SAMBAPATH
for i in $LIST; do
        if (file -ib $i | grep $LOOKFOR > /dev/null 2>&1>/dev/null); then
                echo $i >> $EXE
        fi
done

cat $EXE | while read index; do mv $index /tmp/quarantine/;done;
rm $EXE

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to encrypt the xls file using executable jar in Linux SUSE 11.4

Dear Experts, I am an ERP consultant and would like to learn shell script. We are working on Linux SUSE 11.4 and I am very new to shell scripting. We can manually encrypt an excel file using "executable jar" through command prompt by placing the jar file & the file to be encrypted on a physical... (1 Reply)
Discussion started by: nithin226
1 Replies

2. Shell Programming and Scripting

Move script from windows to Linux using NFS mount

Hi All, Is there a command or script which will push a file from Windows server to Linux box? using the mount command. I want the details or document of the whole process please. I want this script to run every 30 minutes to push the file from windows to unix Thanks (16 Replies)
Discussion started by: thinkingeye
16 Replies

3. Shell Programming and Scripting

Get the File name of perl executable in Linux

Hi All, I just want to know how to get the executable name of the perl script as i know "$0" will give me the script name but i want to know the executable name which i got it from the script using pp command. Regards Raj (1 Reply)
Discussion started by: kar_333
1 Replies

4. UNIX for Dummies Questions & Answers

Run executable in one directory and then move to another successively

Hello, I have several hundred subdirectories which contain input files for a binary executable. I need to get into each of the subdirectories, run the executable and then move to the next one and repeat the process. What is the best way to do this? Arbitrarily my file structures look like... (3 Replies)
Discussion started by: Gussifinknottle
3 Replies

5. UNIX for Dummies Questions & Answers

What are the executable file formats in Solaris and Linux?

we all knew that .exe files are the executable file formats in windows....... Similarly, what are the executable file formats in solaris and linux ........ please tell me:D Thanks in Advance. (2 Replies)
Discussion started by: vamshigvk475
2 Replies

6. UNIX for Dummies Questions & Answers

[Solved] About commands for linux executable files

I have seen commands like this: (hello is the executable file or maybe script file) ./hello hello .hello So, anyone could tell me the differences among these commands? (2 Replies)
Discussion started by: icyfight
2 Replies

7. Linux

Size of the Library/Executable is high in LINUX

HI All, We have a 32bit Gui application created using C++. We ported the application from Solaris to Linux. Issue we are facing is the size of the library and executable is very large in LINUX compared to Solaris. Red Hat Enterprise Linux 5.4 is the Linux version we using. Please... (0 Replies)
Discussion started by: sanushchacko
0 Replies

8. UNIX for Dummies Questions & Answers

Linux PHP Executable Output Issue with IE

I have developed a PHP web page that executes a batch file and pipes the output to a file. It works fine when using Firefox, Safari, etc. However, when using IE, it does not work. $execute = `batch.bat $var1 $var2 | tee /batch.output`; print "<pre>$execute</pre>"; When the page is run in... (1 Reply)
Discussion started by: dleblanc67
1 Replies
Login or Register to Ask a Question