#!/usr/bin/ksh for pid in `ps -ef -o pid | tail +2` do foundport=`pfiles $pid 2>&1 | grep "sockname: AF_INET" | grep -v "port: 0" | awk '{print $NF}'` if [ "$foundport" != "" ]; then foundproc=`pfiles $pid 2>&1 | grep "^$pid:"` echo "$foundprocn$foundport" fi done exit
Monthly Archives: October 2012
Set up ssh tunnel for VNC
jamesmini:~ james$ more ~/.profile ... alias sshhome="ssh user@my.home.com -p 1234 -L 1234:ip.of.vnc.dest:5900 -L 3128:ip.of.server:3128" ...
Linux – Show only directories with over a certain number of files
/mnt/music/sorted$ dir=/mnt/music/sorted; for i in `ls $dir`; do wc=`ls -l $dir/$i | grep ^- | wc -l`; if [ $wc -gt 30 ]; then echo "$i -> $wc" ; fi; done;
Linux – List only files
james@server:/mnt/music$ ls -l | grep ^- | awk '{print $8}'
PERL script to migrate / rename files
Script to look in dir & get album name & create dir of album name then migrate files into dir & rename them Required File Name: ARTIST_-_ALBUM_-_TRACKNUM_-_TITLE.mp3
#!/usr/bin/perl use Getopt::Long; use File::Copy; my $artist; my $dir = "/mnt/music/sorted"; $result = GetOptions("artist=s" => $artist); $dir = $dir . "/" . $artist; opendir(my $dh, $dir) or die "Can't open $dir: $!"; if(!($artist)){ print ("ERROR!!! Must define artistn"); exit(1); } my @files = sort grep { -f "$dir/$_" } readdir($dh); foreach(@files) { if($_ =~ /$artist_-_(.*)?_-_(d*)_-_(.*).mp3/) { $_ =~ /$artist_-_(.*)?_-_(d*)_-_(.*).mp3/; my $album = $1; my $tracknum = $2; my $title = $3; #print $album . " - " . $tracknum . " - " . $title . "n"; #print ($_ . "n"); my $albumdir = $dir . "/" . $album; if(! -d $albumdir) { mkdir $albumdir; } my $new_file_name = $tracknum . "_-_" . $title . ".mp3"; #print("mv $dir/$_ $albumdir/$new_file_namen"); move("$dir/$_", "$albumdir/$new_file_name"); #chdir($albumdir); #my $cmd = "rename -n s/^" . $artist . "_-_" . $album . "_-_// *"; #print(`$cmd` . "n"); #print($cmd . "n"); #chdir($dir); } else { print($_ . " DOES NOT MATCHn"); } }
MySQL – Create User
mysql> create database dbname; Query OK, 1 row affected (0.02 sec) mysql> grant all privileges on dbname.* to 'username'@'%' identified by 'password'; Query OK, 0 rows affected (0.00 sec) mysql> grant all privileges on dbname.* to 'username'@'localhost' identified by 'password'; Query OK, 0 rows affected (0.00 sec)
MySQL – Clone DB
 mysqladmin create <new_db_name> -u <user> --password=<password> && mysqldump -u <user> --password=<password> <db_name> | mysql -u <user> --password=<password> -h localhost <new_db_name>
Maven Release Plugin – Create new branch & don’t increment version number in pom.xml
mvn --batch-mode release:branch -DbranchName=blackberry-4.2.2.x -DupdateBranchVersions=true -DupdateWorkingCopyVersions=false -DreleaseVersion=4.2.2.1-SNAPSHOT
Maven Release Plugin – Create new branch & increment version number in pom.xml
mvn release:branch -DbranchName=5.0.x-SNAPSHOT -DupdateBranchVersions=true
Maven Release Plugin – change version number in pom.xml
mvn --batch-mode release:update-versions -DdevelopmentVersion=1.0.0-SNAPSHOT