steveland? wrote: Sorry to butt in... but can someone please explain how to implement these scripts?
#!/bin/bash
chmod 500 file
#!/bin/bash # cd copy script defpath="/usr/local/luna/public/shared/" permission="1444" # echo "This script will aid in copying a CD or DVD to disk" echo "please enter the location where you wish to save the" echo "disk ISO to, excluding the .iso file extension" echo echo -n "<install path:> $defpath" read usrpath echo mkdir -pv $defpath$usrpath dd bs="32" if="/dev/cdrom" of="$defpath$usrpath.iso" chmod -Rv $permission $defpath$usrpath eject
#!/bin/bash # config host="luna" installpath="/usr/local/$host" # users usr[0]="public" usr[1]="usr1" usr[2]="usr2" usr[3]="usr3" usr[4]="usr4" # permissions - umask permit[0]="0777" permit[1]="0755" permit[2]="0755" permit[3]="0755" permit[4]="0755" function main() { # data members local i=0 while [ $i -lt 5 ]; do chmod "${permit[$i]}" -R "$installpath/${usr[$i]}" echo "${usr[$i]} - ${permit[$i]}" # increment i=$((++i)) done } ## main entry ## main
#!/bin/bash dd if=/dev/cdrom bs=1 skip=32808 count=32 > /tmp/title DVDTITLE=`cat /tmp/title | awk '{print $1}' ` mplayer dvd:// -frames 1 -nosound -vo null > /tmp/mpr TITLENUM=`cat /tmp/mpr | grep "titles" | awk '{print $3}'` echo "DVD Label: $DVDTITLE Titles: $TITLENUM" mkdir $DVDTITLE for i in `seq 1 $TITLENUM`; do rm -f divx2pass.log frameno.avi mencoder -ovc xvid -xvidencopts pass=1:bitrate=1100 -nosound -vf pullup,pp=md dvd://$i -o /dev/null mencoder -ovc xvid -xvidencopts pass=2:bitrate=1100 -nosound -vf pullup,pp=md dvd://$i -o "/tmp/tmp.avi" mplayer -vo null -aid 128 -ao pcm:file="/tmp/tmp.wav" dvd://$i oggenc -q 3 "/tmp/tmp.wav" "/tmp/tmp.ogg" ogmmerge -o "./$DVDTITLE/Title $i.ogm" /tmp/tmp.avi /tmp/tmp.ogg done
#!/bin/sh for img in `ls *.JPG` do convert -resize 1024x768 $img resized-$img done
sicruise wrote: rm -rf
#! /bin/bash # apup: script to upgrade system if [ "$1" = "-d" ]; then echo "dist-upgrade" sudo aptitude update && sudo aptitude dist-upgrade else echo "regular upgrade" sudo aptitude update && sudo aptitude upgrade fi
$ apup regular upgrade Password: Reading package lists... Done Building dependency tree... Done Reading extended state information Initializing package states... Done Building tag database... Done etc...
$ apup -d dist-upgrade Password: Reading package lists... Done Building dependency tree... Done Reading extended state information Initializing package states... Done Building tag database... Done etc...
for fileName in `ls $DIRECTORY | egrep -i ".jpg|.gif|.png|.bmp|.svg"`
#!/usr/bin/perl use Net::Telnet; use Net::Ping; $remote_host = 'some.remote.site'; $local_host = 'router.local.address'; $log_file = '/var/log/router_mon'; $remote_ping = Net::Ping->new(); $rebooted = 0; if(!$remote_ping->ping($remote_host)){ while (!$remote_ping->ping($remote_host)) { $local_ping = Net::Ping->new(); exit 0 if !$local_ping->ping($local_host); $t = new Net::Telnet(); $t->open($local_host); $t->print('admin'); $t->waitfor('/Password:/'); $t->print('my_password'); $t->waitfor('/Belkin>/'); $t->print('reboot'); $t->close(); while (!$local_ping->ping($local_host)) { sleep(20); } $local_ping->close(); $t->close; $rebooted++; } $remote_ping->close(); } $t = new Net::Telnet(); $t->open($local_host); $t->print('admin'); $t->waitfor('/Password:/'); $t->print('my_password'); $t->waitfor('/Belkin>/'); $t->print('ifconfig ppp0'); $t->waitfor('/has_ip=/'); $t->waitfor('/ip=/'); ($ip_addr, $match) = $t->waitfor('/,/'); $t->print('exit'); $t->close; open (FH, "+< $log_file") or die; while ( $line= <FH> ) {$ip_old = $line;} chomp $ip_old; if(!($ip_old eq $ip_addr)){ print FH "$ip_addr\n"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $to='my_email_address@gmail.com'; $from= 'my_email_address@gmail.com'; $subject = sprintf("new server ip %s",$ip_addr); $body = sprintf("system rebooted %u times at %u:%u on the %u/%u/%u, ip address obtained was: %s.",$rebooted,$hour,$min,$mday,$mon,$year+1900,$ip_addr); open(MAIL, '|/usr/sbin/sendmail -t'); print MAIL "To: $to\n"; print MAIL "From: $from\n"; print MAIL "Subject: $subject\n"; print MAIL "Content-type: text/plain\n\n"; print MAIL "$body \n\n"; close(MAIL); } close FH;
#!/bin/sh I=0 SPIN="[= ]" echo -n "DEBUG: Test running ${SPIN}" while [ $I -lt 60 ] do tput cub 13 case $SPIN in "[= ]") SPIN="[ = ]";; "[ = ]") SPIN="[ = ]";; "[ = ]") SPIN="[ = ]";; "[ = ]") SPIN="[ = ]";; "[ = ]") SPIN="[ = ]";; "[ = ]") SPIN="[ = ]";; "[ = ]") SPIN="[ = ]";; "[ = ]") SPIN="[ = ]";; "[ = ]") SPIN="[ = ]";; "[ = ]") SPIN="[ =]";; "[ =]") SPIN="[= ]";; esac echo -n "${SPIN}" sleep 1 I=`expr $I + 1` done tput cub 13 echo "[===DONE!===]"
gamblitis wrote: » Right since your all sticking up scripts does anyone know a script to communicate with meteor.ie to send the free texts.I've seen it been done so i know its possible.I just cant find it anywhere.Just wondering if somebody here might have had one or know where to get one.
#!/usr/bin/perl #Downloads the xkcd archive from http://imgs.xkcd.com/comics/ #Released for totally free use for anyone who wishes to! @args1 = ("wget","http://imgs.xkcd.com/comics/"); system(@args1); #call wget to get the html of the list open (FILE, "<index.html") or die($!); foreach(<FILE>){ if (/<tr><td class="n">/){ #only the lines that are links to comics contain this string s/.*?>.*?>.*?>(.*?)<.*/$1/; #regex strips html and leaves behind "the_comic_name.png" print "$_\n"; chomp ($comic = $_); #get rid of trailing newline character @args2 = ("wget","http://imgs.xkcd.com/comics/"."$comic"); print "Obtaining $comic..\n"; system(@args2); #get the actual comic print "[OK]\n"; } } close FILE or die($!); @args3 = ("rm","index.html"); #erase the html page so script will work next time system(@args3);
#!/usr/bin/perl @args1 = ("wget","http://xkcd.com/"); system(@args1); #call wget to get the html open (FILE, "<index.html") or die($!); foreach(<FILE>){ if (/<h3>Image URL/){ #find the link for hotlinking s/.*?: {1}(.*?)<.*/$1/; #strip html chomp; print "Obtaining comic.."; @args2 = ("wget","$_"); system(@args2); print "[OK]\n"; } } close FILE or die($!); @args3 = ("rm","index.html"); #erase the html page so script will work next time system(@args3);
#!/usr/bin/perl #Kill the process named as the first argument. my $doomed = @ARGV[0]; #get the name of the process open (FILE, ">processes.txt") or die($!); print (FILE `ps -e`); #get list of processes close FILE,open (FILE, "<processes.txt") or die($!); foreach(<FILE>){ if (/$doomed/){ #find line with the selected process /(.*?)\s/; #get the PID print"Killing $doomed with a PID ". "of $1..\n"; $pid = $1; #the PID @args= ("kill","$pid"); $status = system(@args);#try to kill and capture #exit status if ($status eq "0"){ print "Killed.\n"; exit;#end the program }else{ die("Unable to kill $doomed.\n"); } } } #only way to get here is to not have died- meaning the if statement #was never entered, hence: print "No process named $doomed found currently running.\n";
karlreid@karlreid-laptop:~$ killthis conky Killing conky with a PID of 24584.. Killed. karlreid@karlreid-laptop:~$
karlreid@karlreid-laptop:~$ sudo conky [sudo] password for karlreid: Conky: /home/karlreid/.conkyrc: 7: config file error Conky: use_spacer should have an argument of left, right, or none. 'yes' seems to be some form of 'true', so defaulting to right. Conky: diskio device '19' does not exist Conky: forked to background, pid is 24749 karlreid@karlreid-laptop:~$ Conky: desktop window (10000b4) is subwindow of root window (13b) Conky: window type - normal Conky: drawing to created window (3200001) Conky: drawing to double buffer karlreid@karlreid-laptop:~$ killthis conky Killing conky with a PID of 24749.. Unable to kill conky. karlreid@karlreid-laptop:~$ sudo ~/bin/killthis conky Killing conky with a PID of 24749.. Conky: received SIGINT or SIGTERM to terminate. bye! Killed. karlreid@karlreid-laptop:~$
karlreid@karlreid-laptop:~$ killthis nonexistentprocess No process named nonexistentprocess found currently running. karlreid@karlreid-laptop:~$
#!/bin/bash M="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" L="8" while [ $L -gt 0 ] do PASS="$PASS${M:$(($RANDOM%${#M})):1}" let L-=1 done echo "$PASS"
#!/bin/bash cd ~/ read -p "YouTube url? " ur read -p "Name? One word only!! " nv echo;echo; youtube-dl -o ${nv} "${ur}" ffmpeg -i "${nv}" -acodec libmp3lame -ab 160k -ac 2 -ar 44100 "${nv}.mp3" mv "${nv}.mp3" ~/Desktop/"${nv}.mp3" rm ${nv} echo;echo; echo "Your new MP3 file is saved on your Desktop." read
#!/bin/sh MAILTO="your.email@address.here" ######################################################################################## ## Setup Proxy - if you need one, otherwise comment this line out ######################################################################################## export http_proxy='http://1.2.3.4:8080' ######################################################################################## ## Penny Arcade - Nerd/Gamer Humour ######################################################################################## URLBASE="http://www.penny-arcade.com" wget -O page.html ${URLBASE}/comic/ IMGURL=`grep simplebody page.html | awk -F'"' '{print $4}'` wget -O pennyarcade.jpg ${URLBASE}/${IMGURL} ######################################################################################## ## Dilbert - IT Work Humour ######################################################################################## URLBASE="http://www.dilbert.com" wget -O page.html ${URLBASE} IMGURL=`grep -A1 STR_Content page.html | tail -1 | awk -F'"' '{print $4}'` wget -O dilbert.gif ${URLBASE}/${IMGURL} ######################################################################################## ## XKCD - Geek Humour ######################################################################################## URLBASE="http://xkcd.com" wget -O page.html ${URLBASE} IMGURL=`grep -A7 rnd_btn_t page.html | tail -1 | awk -F'"' '{print $2}'` wget -O xkcd.png ${IMGURL} ######################################################################################## ## Dinosaur Comics - Bizzare Humour ######################################################################################## URLBASE="http://www.qwantz.com" wget -O page.html ${URLBASE} IMGURL=`grep 'qwantz.com/comics/' page.html | grep -v facebook | awk -F'"' '{print $2}'` wget -O dc.png ${IMGURL} ######################################################################################## ## Redmeat - Bizzare Humour ######################################################################################## URLBASE="http://www.redmeat.com/redmeat/current" wget -O page.html ${URLBASE}/index.html IMGURL=`grep -A1 'weeklyStrip' page.html | tail -1 | awk -F'"' '{print $2}'` wget -O redmeat.gif ${URLBASE}/${IMGURL} ######################################################################################## ## Least I could do.... ######################################################################################## URLBASE="http://www.leasticoulddo.com" wget -O page.html ${URLBASE}/ IMGURL=`grep -A1 'comic' page.html | grep 'archive.leasticoulddo.com' | tail -1 | awk -F'"' '{print $2}'` wget -O licd.gif ${IMGURL} ######################################################################################## ## Garfield Minus Garfield ######################################################################################## URLBASE="http://garfieldminusgarfield.net/" wget -O page.html ${URLBASE}/ IMGURL=`grep "media.tumblr" page.html | awk -F'"' '{print $4}' | head -1` wget -O garfieldminusgarfield.png ${IMGURL} ######################################################################################## ## Bigger than Cheeses ######################################################################################## URLBASE="http://www.biggercheese.com/" wget -O page.html ${URLBASE}/ IMGURL=`cat page.html | grep -A1 OnlineComics.net | grep img | awk -F'"' '{print $4}'` wget -O btc.png ${URLBASE}/${IMGURL} ######################################################################################## ## Cyanide and Happiness ######################################################################################## URLBASE="http://www.explosm.net/comics/" wget -O page.html ${URLBASE}/ IMGURL=`cat page.html | grep Archive | awk -F'"' '{print $32}'` wget -O cah.png ${IMGURL} ######################################################################################## ## PvP ######################################################################################## URLBASE="http://www.pvponline.com/" wget -O page.html ${URLBASE}/ IMGURL=`grep 'pvponline.com/comics' page.html | awk -F'"' '{print $2}'` wget -O pvp.gif ${IMGURL} ######################################################################################## ## Email the comics ######################################################################################## echo "Hullo," > body.txt echo >> body.txt echo "Please find attached your daily dose of comic humour" >> body.txt echo >> body.txt echo "Todays batch includes:" >> body.txt echo >> body.txt echo " * Penny Arcade" >> body.txt echo " * Dilbert" >> body.txt echo " * Dinosaur Comics" >> body.txt echo " * XKCD" >> body.txt echo " * Redmeat" >> body.txt echo " * Least I could Do" >> body.txt echo " * Garfield minus Garfield" >> body.txt echo " * Bigger than Cheeses" >> body.txt echo " * Cyanide and Happiness" >> body.txt echo " * PvP (Player vs Player)" >> body.txt echo >> body.txt echo "If you have a favourite comic you'd like added, let Dave know..." >> body.txt echo >> body.txt echo "Regards" >> body.txt echo "Daves Comic Trawling Web Monkey" >> body.txt cat body.txt | mutt -s "Comics for today - `date -I`" -a pennyarcade.jpg -a dilbert.gif -a xkcd.png -a dc.png -a redmeat.gif -a licd.gif -a garfieldminusgarfield.png -a btc.png -a cah.png -a pvp.gif $MAILTO ######################################################################################## ## Clean up ######################################################################################## rm -f body.txt page.html *.jpg *.png *.gif
#!/bin/sh find /tmp -maxdepth 1 -name "Flash*" -type f -prune -exec ffmpeg -i '{}' -acodec libmp3lame -ab 160k -ac 2 -ar 44100 '{}.mp3' \; find /tmp -maxdepth 1 -name "*.mp3" -prune -type f -exec mv '{}' ~/Desktop/ \;
if [ -n "$1" ] then if [ -d "$1" ] then cd "$1" else echo invalid directory exit fi fi for i in * do OLDNAME="$i" NEWNAME=`echo "$i" | tr ' ' '_' | tr A-Z a-z | sed s/_-_/-/g` if [ "$NEWNAME" != "$OLDNAME" ] then TMPNAME="$i"_TMP echo "" mv -v -- "$OLDNAME" "$TMPNAME" mv -v -- "$TMPNAME" "$NEWNAME" fi if [ -d "$NEWNAME" ] then echo Recursing lowercase for directory "$NEWNAME" $0 "$NEWNAME" fi done
z0oT wrote: » Here's one that'll replace the spaces in filenames with an underscore. It's handy if you want to loop one program through a directory that doesn't like spaces in filenames. <snip>
#!/bin/sh #Script to compile and run C++ source file # ./cr.sh [source filename without .cpp extension] [arguments to be passed to compiled program] #Check if file exists if [ ! -e "$1.cpp" ] then echo "Error: $1.cpp not a file!" exit 1 fi #Does program file exist? If not compile. if [ ! -e "$1" ] then g++ ./$1.cpp -o $1 else #Has source been modified since last compile? If so compile if test $(stat --format=%Y $1) -lt $(stat --format=%Y $1.cpp) then g++ ./$1.cpp -o $1 fi fi #Grab arguementes to pass to C++ program TEMP=`echo $* | awk '{print substr( $0, index($0," ")+1, length($0)-index($0," ")+1 ) }'` if [ ! -e $2 ] then ./$1 $TEMP else ./$1 fi