Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to get this bash script that i found on a forum to work.

Copied it to text editor. Saved it as script.sh

chmod 700 and tried to run it.

rootdir="/usr/share/malware"
day=`date +%Y%m%d`

url=`echo "wget -qO - http://lists.clean-mx.com/pipermail/viruswatch/$day/thread.html |\
awk '/\[Virus/'|tail -n 1|sed 's:\": :g' |\
awk '{print \"http://lists.clean-mx.com/pipermail/viruswatch/$day/\"$3}'"|sh`

filename=`wget -qO - http://lists.clean-mx.com/pipermail/viruswatch/$day/thread.html |\
awk '/\[Virus/'|tail -n 1|sed 's:": :g' |awk '{print $3}'`

links -dump $url$filename | awk '/Up/'|grep "TR\|exe" | awk '{print $2,$8,$10,$11,$12"\n"}' > $rootdir/>$filename

dirname=`wget -qO - http://lists.clean-mx.com/pipermail/viruswatch/$day/thread.html |\
awk '/\[Virus/'|tail -n 1|sed 's:": :g' |awk '{print $3}'|sed 's:.html::g'`

rm -rf $rootdir/$dirname
mkdir $rootdir/$dirname

cd $rootdir

grep "exe$" $filename |awk '{print "wget \""$5"\""}' | sh 
ls *.exe | xargs md5 >> checksums
mv *.exe $dirname

rm -r $rootdir/*exe*
mv checksums $rootdir/$dirname
mv $filename $rootdir/$dirname

I get the following message..

script.sh: line 11: /usr/share/malware/: Is a directory

script.sh: line 11: links: command not found

share|improve this question
    
I recommend you to use the Ubuntu Pastebin site to post your code and link it. So you won't lose any character and make it more clear. –  Lucio Sep 17 '12 at 20:23
3  
What do you expect it to do? Where did you find it? And the errors speak for themselves. You do not have links installed and output is being redirected to $rootdir/, which is not a file, but a directory. –  gertvdijk Sep 17 '12 at 20:23
    
@lucio thanks.. will do it next time. –  Sunil J Sep 17 '12 at 21:46
    
@gertvdijk from offensivecomputing. I have asked for clarification there too. I should have mentioned that I am not very good in Linux. This script should help me get malware for analysis. –  Sunil J Sep 17 '12 at 21:48
    
do you have links installed? sudo apt-get install links –  j0h Apr 26 at 2:19

1 Answer 1

You have two problems. One you do not have links installed, install it by running sudo apt-get install links and second on line 11 you have this:

[SNIP] > $rootdir/>$filename

This does nothing. It says to redirect it to a directory. If you want the output written to / you should instead have it say

[SNIP] > $rootdir/$filename
share|improve this answer
    
$rootdir/>$filename happened when i tried to format it. Checked and verified that it is showing $rootdir/$filename. the code is pasted at link. now I am getting script.sh: line 11: /usr/share/malware/: Is a directory URL expected after -dump –  Sunil J Sep 17 '12 at 21:54
    
Well then it appears that $filename does not contain any string when it gets to that line. Put in echo $filename's throughout the file to try to see where it disappears, also check and make sure that that is not a typo (maybe it should be $file or $name or something). –  Alex L. Sep 18 '12 at 14:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.