Script to create a specific WSPR call csv file

Posted by admin | Posted in Misc Scripts | Posted on 02-01-2012-05-2008

0

I had the need to download a number of WSPR CSV files so I threw together a PowerShell script.  In case anyone has the same need here is the PowerShell code to use as is at your own risk.  It goes out to the WSPR web site and downloads the month you specify unzips the file and then creates a CSV file of only spots with the call specified, then it deletes the downloaded ZIP and CSV files leaving only a file by the name of the call specified .csv.  This was coded for a quick project and DOES NOT have any type of error checking and it assumes you know what input parameters are needed.  I called the script download.ps1 and it needs three parameters: the year, month and call.

 

# Script to download WSPR spot file, unzip it and create a file with spots for only the specified  call.

# By N9RO January 01, 2012

# To run program CD to the script’s directory and type ./download.ps1 year month call in the

# PowerShell window.  New file will appear the the script’s directory.

 

param($year,$month,$call)

$source = “http://wsprnet.org/archive/wsprspots-$year-$month.csv.zip”

echo “***** Downloading file from: $source *****”

Get-Date -DisplayHint time

$destination = “c:\projects\wspr-adif\wsprspots-$year-$month.csv.zip”

$wc = New-Object System.Net.WebClient

$wc.DownloadFile($source, $destination)

echo “***** File Download Complete *****”

 

# Now unzip File

echo “***** Unzipping WSPR File *****”

Get-Date -DisplayHint time

$shell_app=new-object -com shell.application

$filename = “wsprspots-$year-$month.csv.zip”

$zip_file = $shell_app.namespace((Get-Location).Path + “\$filename”)

$destination = $shell_app.namespace((Get-Location).Path)

$destination.Copyhere($zip_file.items())

echo “***** Unzip complete *****”

 

# Create Call file

echo “***** Creating WSPR Call File for $call *****”

Get-Date -DisplayHint time

$csvfile = “C:\projects\wspr-adif\wsprspots-$year-$month.csv”

Select-String -Simple $call $csvfile >> “$call.csv”

echo “***** Call file created for $call *****”

 

# Delete files not needed

echo “***** Deleting Files Not  Needed *****”

Get-Date -DisplayHint time

Remove-Item “$csvfile”

Remove-Item “$filename”

echo “***** Files deleted *****”

 

Get-Date -displayhint date

Get-Date -DisplayHint time

echo “========== WSPRDB Program Complete ==========”

 

Here is what it looks like when I run the program:

PS C:\projects\wspr-adif> ./download.ps1 2011 11 n9ro

***** Downloading file from: http://wsprnet.org/archive/wsprspots-2011-11.csv.zip *****

10:54:23 PM

***** File Download Complete *****

***** Unzipping WSPR File *****

10:55:13 PM

***** Unzip complete *****

***** Creating WSPR Call File for n9ro *****

10:55:16 PM

***** Call file created for n9ro *****

***** Deleting Files Not  Needed *****

10:55:24 PM

***** Files deleted *****

Saturday, December 31, 2011

10:55:24 PM

========== WSPRDB Program Complete ==========

PS C:\projects\wspr-adif>

 

Rig Control With PowerShell

Posted by admin | Posted in Misc Scripts | Posted on 18-09-2011-05-2008

1

Today rig automation is easy and you don’t even need an SDR or a developers
background. Below is a very simple example using PowerShell (Free with
Windows 7) to automate the monitoring of two different frequencies. In this
example I set a simple timer for 10 minutes and then every 30 seconds it
changes between two frequencies. You MUST understand your radios
CAT commands and have a serial port or virtual serial port setup on your
radio. You can easily see how powerful controls could be build. The web
is loaded with PowerShell info and training, this example is being used with
my Flex radios.

$waitMinutes = 10
$startTime = get-date
$endTime = $startTime.addMinutes($waitMinutes)
$timeSpan = new-timespan $startTime $endTime
while ($timeSpan.minutes -gt 0 ) {
$port= new-Object System.IO.Ports.SerialPort COM7,9600,None,8,one
$port.open()
$port.WriteLine(“FA00014272000;”)
$port.Close()
Start-Sleep -s 30
$port= new-Object System.IO.Ports.SerialPort COM7,9600,None,8,one
$port.open()
$port.WriteLine(“FA00014313000;”)
$port.Close()
Start-Sleep -s 30
$now = get-date
$timeSpan = new-timespan $now $endTime
}

If you want to check what com ports you have run the following PowerShell
command. Note: This does NOT tell you what is being using only what ports
are configured on the system.

[System.IO.Ports.SerialPort]::getportnames()

Below is what the PowerShell command above produced on my system.
You can sort list if needed.

PS C:\Users\tim> [System.IO.Ports.SerialPort]::getportnames()

COM11
COM12
COM15
COM16
COM1
COM2
COM3
COM4
COM5
COM6
COM7
COM8
COM9
COM10

PS C:\Users\tim>

WSPR Monitor Script

Posted by admin | Posted in Misc Scripts | Posted on 18-09-2011-05-2008

0

A few days ago I read someone was going to run WSPR on a VLF band, I wanted to lurk the band to see if I could capture any signal. I quickly put together a little PowerShell script that checks the WSPR database every15 minutes and if I had reported a capture it would email me a notice along with a copy of the WSPR DB Web Page which I could view in a browser. In addition, on the screen you also see the date/time when the last query took place and when the next is scheduled and how long it took to process the last request. I could go on with my life and if something occurred I would be notified and I could look at the web page and decide if I wanted to run to the rig and see what was happing. Below is the script as is no warranty if you want to try it, you will need to change “CALLYOUARESEARCHINGFOR” to a real call sign, the “SMTPMAILSERVER” to your SMTP mail server, “FROMADDRESS’ to the from Email address, “TOADDRESS’ to the To Email address. In the output line set the band (here it is 15) and the reporter (here it is n9ro ) and you should be good to go. Everything you ever wanted to know regarding PowerShell is out on the web. Please respect the WSPR web site and don’t use needlessly.

$webClient = new-object System.Net.WebClient
$webClient.Headers.Add(“user-agent”, “PowerShell Script”)
$interval = 900 #Time in seconds to wait
while (1 -eq 1) {
$output = “”
$startTime = get-date
$output = $webClient.DownloadString(“http://wsprnet.org/olddb.php?mode=html`
&band=15&limit=100&findcall=&findreportern9ro=&sort=date HTTP/1.1″)
$output | out-file -encoding ASCII wspr.html
$endTime = get-date
if ($output -like “*CALLYOUARESEARCHINGFOR*”) {
“Success`t`t” + $startTime.DateTime + “`t`t” + ($endTime – $startTime).`
TotalSeconds + ” seconds”

Send-MailMessage -smtpServer ‘SMTPMAILSERVER’ -from ‘FROMADDRESS’ -to ‘TOADDRESS’ -subject ‘WSPR Spot’ -body “WSPR Data Attached” -attachment wspr.html

} else {
“Fail`t`t” + $startTime.DateTime + “`t`t” + ($endTime – $startTime).TotalSeconds`
+ ” seconds”
}

$nowtime = Get-Date -displayhint time
$next = (Get-Date).AddSeconds($interval)
echo “Current Time is: $nowtime Next Query Is At: $next ”
sleep($interval) #Wait interval then try again
}

If it finds the call you specified it shows success if not Fail. See below:

ps1-1

Below is a sample web page that was mailed during it’s use:

ps1-2

Remember to use .\ to run the script from the scripts directory and make sure you have permissions for running a PowerShell script.