Monday, April 23, 2018

BBC : Downloading the sound effects.



Complete link:

BBC is offering about 16000 of their sound files for download, under RemArc License.

If you wish to use their files, please read their terms and conditions.

Now that is clear, I put together a powershell script to download the files. Have fun!

Import-Module BitsTransfer

$csv=Import-Csv -Path c:\tmp\BBC-Sounds\BBCSoundEffects.csv
foreach ($line in $csv) {
#Write-Host $URL$uri
#Write-Host $fn
Start-BitsTransfer -Source $URL$uri -Destination $fn

Monday, December 28, 2015

AWS Shell

Came across the easy to use shell for AWS -

Appears pretty handy.

Friday, November 13, 2015

A simple script to verify that the DNS update has propagated (Bash/Unix)

Same premise as the Windows/powershell one, but this is for Bash / Unix.

while(true); do

for domain in `cat domains.txt`; do

echo -en $domain ":" ;

for i in dnsserver1 dnsserver2 dnsserver3 ; do echo -en $i $(dig +short NS @$i $domain | grep dns.ap | wc -l) "\t";


echo "" ;
done ;
sleep 10;


Wednesday, November 11, 2015

A simple script to verify that the DNS update has propagated (Powershell / Windows)

Background: We updated a few name server records and removed references to AP ones. And this script simply queries your DNS and ensures that the removed one has been propagated.

domains.txt is self-explanatory - has all the (removed) domains listed, one per line.

while ($true){ foreach ($dns in get-content .\domains.txt) 
if (Resolve-DnsName -type NS $dns | findstr /i "dns.ap") { } else { Write-host "$dns no AP" } 

 start-sleep -s 120


Tuesday, June 02, 2015

wmic: Getting process (and arguments!) in a remote server

wmic can be very convenient to obtain information about the processes running on a remote server.

I downloaded a VM from for testing. (It's valid only for 30 days and doesn't permit to be licensed!) and have been testing it.

A curious question came in - how to find remote processes in a windows PC using wmic? How will you get the complete arguments?

C:\>wmic /node:ie8winxp /user:IE8WINXP\Administrator /password:Passw0rd! /output:stdout process list /format:htable " > c:\temp.html

Note that the redirection above will be to local desktop's c:\temp.html, not remote c:\temp.html

If you wish to redirect to an internal file in the remote PC, you can simply save the command in the remote host and call it.


Save the below as a file, say c:\temp\1.bat

wmic process list /format:htable > c:\temp.html

Call it using :

C:\>wmic /node:ie8winxp /user:IE8WINXP\Administrator /password:Passw0rd! process call create "C:\temp\1.bat"

Examples at :

And more at:

Simple bash scripts (work in progress!)

Have been focussing on scripting bash programs and managed to write some scripts.

A simple script to replace softlinks with target files:

          $ for i in `find . -type l -print`; do

          mv -v $(readlink $i) $i

You can, replace `` with $(). Also, include $i in quotes as well if you wish.

Friday, May 08, 2015

Powershell v3: How to check if a PC is up for > 30 days

step 1- Check uptime. If > 30 days, then go for step 2; else exit step 2- Check if desktop is unlocked. If yes, popup saying it will be rebooted in next 24 hours. If locked, exit step 3- reboot
Is that accurate? Can be do in powershell.
$computer = "<Computer name>"
 if (Test-Connection $computer -Count 2 -Quiet) {

try {

     $user = $null

     $user = gwmi -Class win32_computersystem -ComputerName $computer | select -ExpandProperty username -ErrorAction Stop
 catch { Write-Host "Not logged on"; return }
 try {
     if ((Get-Process logonui -ComputerName $computer -ErrorAction Stop) -and ($user)) {
        Write-Host "Workstation locked by $user"
 catch { if ($user) 
Write-Host "$user logged on" 
   $wmi = Get-WmiObject -ComputerName $computer -Query "SELECT LastBootUpTime FROM Win32_OperatingSystem"

$now = Get-Date

$boottime = $wmi.ConvertToDateTime($wmi.LastBootUpTime)

$uptime = $now - $boottime

$d =$uptime.days

$h =$uptime.hours

$m =$uptime.Minutes

$s = $uptime.Seconds
# above h/m/s are optional, but good to have!
if ($d -gt 30) { 
 Write-Host "Greather than 30 days" 
 # call shutdown tool here or do other activities

else { Write-Host "Less than 30 days" }

} }


 else { Write-Host "$computer Offline" }

Linux/Bash: How to report the CPU/ memory usage per user.

for user in `ps -aef | awk '{print $1}' | sort -k1 | uniq | grep -v UID`; do
procs=$(ps -u $user -o user,comm,vsz | wc -l) ;
echo -en $user " : Memory in KiB : " $(ps -u $user -o user,cmd,vsz | grep -v grep | awk 'BEGIN{s=0;} {s=s+$NF;}END{print s/1024}'); echo "" ;
echo -en $user " : CPU% : " $(ps -u $user -eo %cpu | grep -v grep | awk 'BEGIN{s=0;} {s=s+$NF;}END{print s}'); echo "" ;

Another method I learnt was:

ps -eo %cpu=,vsz=,user= |

awk '{ cpu[$3]+=$1; vsz[$3]+=$2 } END { for (user in cpu) printf("%-10s : Memory %10.1f KiB, CPU%%: %4.1f\n", user, vsz[user]/1024, cpu[user]); }'


LC_ALL=C ps -eo %cpu=,vsz=,user= |

awk '{ cpu[$3]+=$1; vsz[$3]+=$2 } END { for (user in cpu) printf("%-10s : Memory %10.1f KiB, CPU%%: %4.1f\n", user, vsz[user]/1024, cpu[user]); }'

And finally:

ps axro "pid,%cpu,ucomm" | awk 'FNR>1' | head -n 3 | awk '{ printf "%5.1f%%,%s,%s",$2,$3,$1 }

ps axo "rss,pid,ucomm" | sort -nr | head -n3 | awk ‘{ printf "%8.0f MB,%s,%s",$1/1024,$3,$2 }

Friday, January 02, 2015

Removing the PrIceLesos 5.2 adware.

Removing the PrIceLesos 5.2 adware.

I got a new iPhone and thought of downloading an emulator.. and after a while, downloaded content from - specifically this one: for my Vista laptop.

And during the installation, I accepted the defaults and didn't look at what it installs. And got an unwelcome adware called PrIceLesos. I got intrusive ads during my normal browsing, highlighting my lack of focus about installing software on home PC. Sigh!

So I decided to remove the adware. Easy - simply go to Chrome > Settings > extensions and disable the PrIceLesos 5.2 adware. Then delete it by clicking on the trashcan button on the same screen. Rebooted.. and thought - 'That should do the trick'. Oh, how wrong I was.

After some googling where people were offering to remove it with their own tools.. which I was weary to install after this misstep. So I decided to dig around. Removed it from control panel - was named PriceLess and Supporter programs on control panel - I removed both.

Still after a reboot I noticed the ads popup - which was annoying. So I decided to enable the developer mode in the chrome extensions - and noticed this for the extension:

PrIceLesos 5.2
ID: kglpgmodaiklggoaaehdphmmmmldaaba
Loaded from: ~\AppData\Local\Google\Chrome\User Data\Default\Extensions\pocibaidmhhbcpkeneeknfbojdnoiibb\5.2

So there it was! I navigated to the path C:\Users\user\AppData\Local\Google\Chrome\User Data\Default\Extensions and deleted the folder called kglpgmodaiklggoaaehdphmmmmldaaba AND pocibaidmhhbcpkeneeknfbojdnoiibb

Still no luck.

So then I noticed something - the adware had made backup copies under
C:\Users\user\AppData\Local\Google\Chrome SxS\User Data\Default\Extensions - and deleted the folder there too. A reboot finally sealed the fate.