Wednesday 26 September 2007

N73 mgmaps download map tiles to your phone

I use following procedure for offline browsing of maps in my mobile phone. So you will not pay for gprs.
http://forum.mgmaps.com/viewtopic.php?t=1116

Briefly,
Download and install Mgmaps into your mobile phone. http://www.mgmaps.com/download.php
Generate map info from this site http://map.outdated.info , you will use map file in the next step.
Download and install mapmaker for creating maps http://www.mgmaps.com/gMapMaker-setup.exe , select map file you created, use proxy option.
Copy files which created to your sd card. configure gmap settings for using offline content.

If you have gps module, GMAP supports gps.

Monday 17 September 2007

Linux Live CD generator

Try this link to generate and download your live cd.
http://custom.nimblex.net/

Understanding Load Average

Please take a look for details:
http://www.teamquest.com/resources/gunther/display/5/index.htm


Summary

So, what have we learned? Those three innocuous looking numbers in the LA triplet have a surprising amount of depth behind them.

The triplet is intended to provide you with some kind of information about how much work has been done on the system in the recent past (1 minute), the past (5 minutes) and the distant past (15 minutes).

As you will have discovered if you tried the LA Triplets quiz, there are problems:

1. The "load" is not the utilization but the total queue length.
2. They are point samples of three different time series.
3. They are exponentially-damped moving averages.
4. They are in the wrong order to represent trend information.

Monday 10 September 2007

Schtasks

I set scheduled tasks with schtasks command to create for all servers.
This command create task which runs every 5 minutes.


schtasks /create /s "\\server" /U domain\username /p "password" /SC MINUTE /MO 5 /tn taskname /tr "scriptpath"

ERROR: passing the user credential on local connection.
You have to give server name in this format "\\server"

Wednesday 5 September 2007

Vbscript encrypt runas

I use this script to run an application with another user rights.
Do not forget to encrypt the script with screnc.exe, and move the file extension vbe



On Error Resume Next
dim WshShell,oArgs,FSO


sUser="domain\user"
sPass="password"&VBCRLF
sCmd="applicationpath"

set WshShell = CreateObject("WScript.Shell")
set WshEnv = WshShell.Environment("Process")
WinPath = WshEnv("SystemRoot")&"\System32\runas.exe"
set FSO = CreateObject("Scripting.FileSystemObject")

if FSO.FileExists(winpath) then
'wscript.echo winpath & " " & "verified"
else
wscript.echo "!! ERROR !!" & VBCRLF & "Can't find or verify " & winpath &"." & VBCRLF & "You must be running Windows 2000 for this script to work."
set WshShell=Nothing
set WshEnv=Nothing
set oArgs=Nothing
set FSO=Nothing
wscript.quit
end if

rc=WshShell.Run("runas /user:" & sUser & " " & CHR(34) & sCmd & CHR(34), 2, FALSE)
wscript.echo "runas /user:" & sUser & " " & CHR(34) & sCmd & CHR(34)
Wscript.Sleep 30 'need to give time for window to open.
WshShell.AppActivate(WinPath) 'make sure we grab the right window to send password to
WshShell.SendKeys sPass 'send the password to the waiting window.

set WshShell=Nothing
set oArgs=Nothing
set WshEnv=Nothing
set FSO=Nothing

wscript.quit

Tuesday 4 September 2007

Vbscript write log file entries to event log

this script reads log files at these server and writes every line to windows event log for the related server.
you can specify search keyword via regex for lines. Please find detailed information here http://msdn2.microsoft.com/en-us/library/ms974570.aspx#scripting05_topic2
change regex details for yourself.
If there is any error when executing script, it sends you an email about the problem.

I use this script Global Array Manager (GAM) log entries for writing them to windows event log. So we can monitor these entries and raise error via MOM.





On Error Resume Next
' v0.2


'Dont forget to update number of servers.
Dim nos
nos=8

dim objFile(100)
dim objFileCopy(100)
dim patika(100)
dim strSearchString(100)
Dim server(100)
Dim xc

'Write hostnames here
server(1)="server1"
server(2)="server2"
server(3)="server3"
server(4)="server4"
server(5)="server5"
server(6)="server6"
server(7)="server7"
server(8)="server8"


LOGSEVERITY=1
mailserver="mailserverip"
mailfrom="gamlog@domain.com"
mailto="your@mail.adress"
path="\c$\"&"Program Files\Mylex\Global Array Manager Client\gam2cl.log"

'Shell object
Set objShell = WScript.CreateObject("WScript.Shell")

'Filesystem Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1

'Regex Object
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = "^\s\s......[0-3]"

'Start checking
For xc= 1 to nos
'Open file
patika(xc)="\\" &server(xc)& path
strFilePath=patika(xc)

'Check if the file exist
If objFSO.FileExists(patika(xc)) Then
Set objFile(xc) = objFSO.OpenTextFile(patika(xc), ForReading)

'Read line by line
Do Until objFile(xc).AtEndOfStream
strSearchString(xc) = objFile(xc).ReadLine
Set colMatches = objRegEx.Execute(strSearchString(xc))
If colMatches.Count > 0 Then
For Each strMatch in colMatches
'wscript.echo strSearchString(xc)
objShell.LogEvent LOGSEVERITY, strSearchString(xc) ,server(xc)
Next
End If
Loop
objFile(xc).Close

'Move file
strDestination=patika(xc) &"_" & Year(now())& Right("0" & Month(now()), 2) & Right("0" & Day(now()), 2) & Right("0" & Hour(now()), 2) & Right("0" & Minute(now()), 2) & Right("0" & Second(now()), 2) &".log"
objFSO.Movefile strFilePath ,strDestination

'If there is an error, send an email
If Err.Number <> 0 then
res="There is a error, check why: http://support.microsoft.com/kb/180751"
Set objEmail = CreateObject("CDO.Message")
objEmail.From = mailfrom
objEmail.to = mailto
objEmail.Subject = "SC Hardware control problem" &" Error Code:" & Err.Number&" "&server(xc)
bodybody= res & vbCr & " Error Code:"& Err.Number
objEmail.Textbody = bodybody
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
mailserver
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
End If
end if
Next

Monday 3 September 2007

Wu-ftp how to restrict a ftp user to home directory

You can restrict user3 to home directry
guestuser user3

Also you can restrict all users and allow some users to other directories.
guestuser *
realuser user1 user2

Python ssh paramiko run command at every server

I have more than 40 linux server and sometimes I need to check something at servers one by one. I got tired and started to use this script.
You have to install paramiko module http://www.lag.net/paramiko/ . You need to have same username for every server. This script asks you a username password and command to execute at servers.


#!/usr/bin/python
#import sys, os, base64, getpass, socket, traceback, termios, tty, select
import paramiko, getpass

serverList = ["ipadress1","ipadress2"]

command=raw_input("Command: ")
userName=raw_input("User: ")
userPass=getpass.getpass("Password: ")

for server in serverList:
t = paramiko.Transport((server,22))
try:
t.connect(username=userName,password=userPass,hostkey=None)
except:
print server + ": Bad password or login!"
t.close()
break
else:
ch = t.open_channel(kind = "session")
ch.exec_command(command)
if (ch.recv_ready):
print server + ": " + ch.recv(1000)
t.close()

Sunday 2 September 2007

Oscommerce insallation in Fedora 7 Linux

Install php
yum install php

Install mysql
yum install mysql

Start httpd service
service start httpd
chkconfig httpd on

Start mysql service
service start mysqld
chkconfig mysqld on

Change password of mysql
/usr/bin/mysqladmin -u root password 'new-password'

install phpMyAdmin
yum install phpMyAdmin

edit /etc/httpd/conf.d/phpMyAdmin.conf if you are not working from local.
edit /etc/phpMyAdmin/config.inc.php and change username and password for mysql

Open url from browser http://localhost/phpMyAdmin
login with mysql username and password
Create a database and user for this database give full access. You will use these information at installation of oscommerce.

Download oscommerce package and extract it under /var/www/html/
Tip: If you extract it in another folder and copy only Catalog folder you will get error:
"You don't have permission to access /catalog/install on this server."

chmod 777 /var/www/html/catalog/includes/configure.php
chmod 777 /var/www/html/catalog/admin/includes/configure.php

open http://localhost/catalog/install/install.php
Supply information and complete configuration.

You can access oscommerce http://localhost/catalog