Search This Blog

Tuesday, October 10, 2017

How to view pictures from the motion detection on Raspberry pi using motion.conf

Your pictures will be saved in /tmp/motion by default.

Create an alias on apache2 virtual host section on the conf file.

just after /var/www directory directive.

////////////

Alias /images /tmp/motion
<Directory /tmp/motion>
Options Indexes FollowSymLinks MultiViews
    Order allow,deny
    Allow from all
  </Directory>

///////////////////////////

Make another file called list.html and put it in the var/www the default doc root for apache.

here is the code for that file.

////////////////////////////////////



<!DOCTYPE html>
<html>
<head>
<script>
var folder = "images/";

$.ajax({
    url : folder,
    success: function (data) {
        $(data).find("a").attr("href", function (i, val) {
            if( val.match(/\.(jpe?g|png|gif)$/) ) { 
                $("body").append( "<img src='"+ folder + val +"'> -->" );
            } 
        });
    }
});
</script>
</head>
<body>


</body>
</html>

////////////////////////////////////

Make sure your /tmp/motion has 755 chmod.

Now restart apache2 and you should see the recent motion detected jpgs on the html browser as shown below.

Also set a cron on the pi to rotate the pictures folder every day or week so that you dont fill up your sdcard.

To find out how to expose this cam running on motion via pi, checkout my earlier tutorial where i explained port forwarding and duckdns.

Monday, October 9, 2017

How to get a public ip for a home camera running on Raspberry pi using motion.conf

IF you have attached a USB webcam to your PI and thinking to view it over the internet here is the way to do it.

Go to duckdns.org and login and get a url and the token.

Go to you pi and create a duckdns.sh script as shown below.

echo url="https://www.duckdns.org/update?domains=nameofcam&token=token&ip=" | curl -k -o /root/test/duckdns/duck.log -K -


Now go to crontab and create a cron entry like this.

*/5 * * * * /root/test/duckdns/duck.sh >/dev/null 2>&1

crontab reload

Make sure script has execute permissions.

Now test the url you specified in duckdns , you should see your camera ip being updated every minute.
Make sure you do a port forward on your router to the wlan ip of the camera.



Friday, September 29, 2017

Import and Merge XLS/CSV data into Maximo Database on Oracle

If you want to update values of certain fields inside database, one option is to make individual update statements in xl formulas as explained in another post and another option if you have huge datasets is to use MERGE commands from Oracle.


Steps:

Create a temporary table in database which will hold our data from CSV/XL

In Oracle SQL developer, click on Table and click data tab-- click action and import.

Navigate to xls/csv make sure column names match and first header has column names.

Import and accept defaults.


Now you have the database with your xl/csv data in table.
Now we will merge it with our actual table.

with below statement.



MERGE into prodtable t using ( select * from temptable) s on (t.location=s.location) 
when matched then
UPDATE SET t.fieldtoupdate = s.fieldtoupdate;


Your user should have insert update create rights on the schema where you are trying to do merge the data.

Keep Reading ! 


Thursday, September 28, 2017

Update Maximo Table Data using insert/update statements from the Excel Sheet into Oracle/SQL Server

If you want to update Maximo tables data with the new data from XLS sheet you can insert a new column in XLS

Lets say new column P

then in the formula bar use this formula if you want to generate  Update sql statements in the P column

= "update location set glaccount = '" & M1& "'  where location = '" & B1& "'"

Now if you want to generate multiple update statement in the complete P column just highlight and enter Ctrl+Enter

You will get a list of SQL statements, copy paste and run on Target Database.