Wednesday, 22 July 2009

More simple bash scripts

Script for start X session automatically, after making login ( without using any login manager)
#!/bin/bash
if (($(ps -A | grep -c X) > 0));
then
echo starting X....;startx;
fi

Script for unzip multiple files. Replacing "zip" extension name and "unzip" command on script, we can change to open other files as well.
#!/bin/bash
for file in *zip
do
unzip "$file"
done

Script to get links from an list every X time, for example, usefull to automatically open download links like rapidshare, netload, megaupload,...
Changing time and application, it can be useful to do lots of things =)
#!/bin/bash
waitTime=3600
app="/usr/bin/firefox"

cat $1 | while myLine=`line`
do
echo "Requesting" $myLine
$app $myLine;
sleep $waitTime && echo ""
done

Some usefull commands
Play random mp3
slocate *.mp3 | mpg321 -@ - -z

Play random mp3 from specific folder
slocate *.mp3 | grep /home/user/files/mp3/new/ | mpg321 -@ - -z

Download links from an text file list
wget -i file.txt

Download recursively all page files
wget -r http://url/folder/

Download sequentially files
curl -O http://url/img[01-99].png

No comments:

Post a Comment