On Error Resume Next
logLocation = WScript.Arguments.Item(0)
Set logFile = CreateObject("Scripting.FileSystemObject")
Set logger = logFile.OpenTextFile(logLocation,2,True)
Set ADSysInfo = CreateObject("ADSystemInfo")
logger.writeline "ComputerName : "&ADSysInfo.ComputerName
logger.writeline "UserName : "&ADSysInfo.UserName
logger.writeline "SiteName : "&ADSysInfo.SiteName
logger.writeline "DomainDNSName : "&ADSysInfo.DomainDNSName
logger.writeline "DomainShortName : "&ADSysInfo.DomainShortName
logger.writeline "ForestDNSName : "&ADSysInfo.ForestDNSName
logger.writeline "IsNativeMode : "&ADSysInfo.IsNativeMode
logger.writeline "PDCRoleOwner : "&ADSysInfo.PDCRoleOwner
logger.writeline "SchemaRoleOwner : "&ADSysInfo.SchemaRoleOwner
For Each var in ADSysInfo.GetTrees
logger.writeline "Tree: " & var
Next
Set objWMIService = GetObject("winmgmts:\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objItem in colItems
logger.writeline "OS : "&objItem.Caption
logger.writeline "ServicePack : "&objItem.ServicePackMajorVersion &"."&objItem.ServicePackMinorVersion
logger.writeline "Build Version : "&objItem.Version
logger.writeline "System Directory: "&objItem.SystemDirectory
logger.writeline "OS Language: "&objItem.OSLanguage
logger.writeline "Current Time Zone: "&objItem.CurrentTimeZone
logger.writeline "CSD Version: "&objItem.CSDVersion
Next
Set Battery = objWMIService.ExecQuery("Select * from win32_battery")
i = 0
For Each objItem in Battery
i = i+1
Next
if i = 0 then
logger.writeline "System : Desktop"
else
logger.writeline "System : NotePad"
end if
Set tcpIp = objWMIService.ExecQuery("Select * from win32_networkadapterconfiguration where ipenabled = true")
For Each objItem in tcpIp
For Each ip in objItem.IPAddress
logger.writeline "IPAddress : "&ip
Next
logger.writeline "MACAddress : "&objItem.MACAddress
For Each gw in objItem.DefaultIPGateWay
logger.writeline "DefaultIPGateWay : "&gw
Next
For Each ds in objItem.DNSServerSearchOrder
logger.writeline "DNSServerSearchOrder : "&ds
Next
logger.writeline "DHCPEnabled : "&objItem.DHCPEnabled
logger.writeline "DHCPLeaseExpires : "&objItem.DHCPLeaseExpires
logger.writeline "DHCPLeaseObtained : "&objItem.DHCPLeaseObtained
logger.writeline "DHCPServer : "&objItem.DHCPServer
For Each ips in objItem.IPSubnet
logger.writeline "IPSubnet : "&ips
Next
Next
if Err Then
logger.writeline Date()&" "&Time()&" "&Err.Number&" "&Err.Description
End if
Thursday, December 29, 2011
Find a Machine on which Domain(WorkGroup)
Dim sName
Dim logFile
'
' Logger
'
Sub Logger
Set fso = CreateObject("Scripting.FileSystemObject")
Set logFile = fso.OpenTextFile( "C:\ComputerList.txt", 8, True )
End Sub
'
' Get all the NetBIOS namespaces
'
Sub PullAllDomains
Dim objNameSpace
Dim AllNameSpaces
Dim Domain
Dim c
c = 0
Set objNameSpace = GetObject("WinNT:")
For Each Domain in objNamespace
AllNameSpaces = AllNameSpaces & VBCRLF & Domain.Name
c = c + 1
if Instr(sName, Domain.Name) <> 0 then
logFile.writeline Domain.Name & " matches"
else
GetComputerList Domain.Name
End if
Next
logFile.writeline "Namespaces :" & c
logFile.writeline AllNameSpaces
End sub
'
' When passed a namespace returns all computers present in it.
'
sub GetComputerList( ContainerName )
Dim Container
Dim Computer
Dim sTemp
Dim filter
Dim counter
filter = "Computer"
counter = 0
Set Container = GetObject("WinNT://" & ContainerName)
Container.Filter = Array(filter)
For Each Computer In Container
sTemp = sTemp & Computer.Name & VBCRLF
counter = counter + 1
Next
logFile.writeline VBCRLF
logFile.writeline "Machines in " & ContainerName & " : " & counter
logFile.writeline sTemp
End Sub
'
' Finds the current workgroup/domain the local machine is present using WMI.
'
Sub GetLocalDomain
sNode = "."
Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& sNode & "\root\cimv2")
Set colComputer = oWMI.ExecQuery _
("Select DomainRole, Domain from Win32_ComputerSystem")
For Each oComputer in colComputer
iDR = oComputer.DomainRole
sName = oComputer.Domain
Next
If iDR = 0 Or iDR = 2 Then
logFile.writeline "Computer is in workgroup " & sName
Else
logFile.writeline "Computer is in domain " & sName
End If
GetComputerList sName
End Sub
Logger
logFile.writeline Date()&":"&Time()&":" & " Starting discovery ..."
GetLocalDomain
PullAllDomains
logFile.writeline Date()&":"&Time()&":" & " End of discovery ..."
' Close the log file.
logFile.Close
Dim logFile
'
' Logger
'
Sub Logger
Set fso = CreateObject("Scripting.FileSystemObject")
Set logFile = fso.OpenTextFile( "C:\ComputerList.txt", 8, True )
End Sub
'
' Get all the NetBIOS namespaces
'
Sub PullAllDomains
Dim objNameSpace
Dim AllNameSpaces
Dim Domain
Dim c
c = 0
Set objNameSpace = GetObject("WinNT:")
For Each Domain in objNamespace
AllNameSpaces = AllNameSpaces & VBCRLF & Domain.Name
c = c + 1
if Instr(sName, Domain.Name) <> 0 then
logFile.writeline Domain.Name & " matches"
else
GetComputerList Domain.Name
End if
Next
logFile.writeline "Namespaces :" & c
logFile.writeline AllNameSpaces
End sub
'
' When passed a namespace returns all computers present in it.
'
sub GetComputerList( ContainerName )
Dim Container
Dim Computer
Dim sTemp
Dim filter
Dim counter
filter = "Computer"
counter = 0
Set Container = GetObject("WinNT://" & ContainerName)
Container.Filter = Array(filter)
For Each Computer In Container
sTemp = sTemp & Computer.Name & VBCRLF
counter = counter + 1
Next
logFile.writeline VBCRLF
logFile.writeline "Machines in " & ContainerName & " : " & counter
logFile.writeline sTemp
End Sub
'
' Finds the current workgroup/domain the local machine is present using WMI.
'
Sub GetLocalDomain
sNode = "."
Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& sNode & "\root\cimv2")
Set colComputer = oWMI.ExecQuery _
("Select DomainRole, Domain from Win32_ComputerSystem")
For Each oComputer in colComputer
iDR = oComputer.DomainRole
sName = oComputer.Domain
Next
If iDR = 0 Or iDR = 2 Then
logFile.writeline "Computer is in workgroup " & sName
Else
logFile.writeline "Computer is in domain " & sName
End If
GetComputerList sName
End Sub
Logger
logFile.writeline Date()&":"&Time()&":" & " Starting discovery ..."
GetLocalDomain
PullAllDomains
logFile.writeline Date()&":"&Time()&":" & " End of discovery ..."
' Close the log file.
logFile.Close
Tuesday, December 13, 2011
Login to FB from java
package test;
import javax.ws.rs.core.MultivaluedMap;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.WebResource.Builder;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.core.util.MultivaluedMapImpl;
public class CallWS {
public static void main(String[] args) throws Exception {
ClientConfig config = new DefaultClientConfig();
com.sun.jersey.api.client.Client client = com.sun.jersey.api.client.Client.create(config);
MultivaluedMap formData = new MultivaluedMapImpl();
formData.add("charset_test","€,´,€,´,水,Д,Є");
formData.add("charset_test","€,´,€,´,水,Д,Є");
formData.add("default_persistent","0");
formData.add("display","");
formData.add("email","YOUR_FACEBOOK_ID");
formData.add("legacy_return","1");
formData.add("login","Log In");
formData.add("lsd","");
formData.add("lsd","");
formData.add("pass","YOUR_FACEBOOK_PASSWORD");
formData.add("return_session","0");
formData.add("session_key_only","0");
formData.add("trynum","2");
System.out.println(formData.toString());
WebResource resource = client.resource("https://www.facebook.com/login.php?login_attempt=1");
// for GET
//ClientResponse response = resource.type("application/x-www-form-urlencoded").get(ClientResponse.class);
Builder builder = resource.type("application/x-www-form-urlencoded");
// for POST
ClientResponse response = resource.queryParams(formData).post(ClientResponse.class, formData);
//ClientResponse response = resource.type("application/x-www-form-urlencoded").post(ClientResponse.class, formData);
String en = response.getEntity(String.class);
System.out.println(en);
System.out.println("oks");
}
}
import javax.ws.rs.core.MultivaluedMap;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.WebResource.Builder;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.core.util.MultivaluedMapImpl;
public class CallWS {
public static void main(String[] args) throws Exception {
ClientConfig config = new DefaultClientConfig();
com.sun.jersey.api.client.Client client = com.sun.jersey.api.client.Client.create(config);
MultivaluedMap formData = new MultivaluedMapImpl();
formData.add("charset_test","€,´,€,´,水,Д,Є");
formData.add("charset_test","€,´,€,´,水,Д,Є");
formData.add("default_persistent","0");
formData.add("display","");
formData.add("email","YOUR_FACEBOOK_ID");
formData.add("legacy_return","1");
formData.add("login","Log In");
formData.add("lsd","");
formData.add("lsd","");
formData.add("pass","YOUR_FACEBOOK_PASSWORD");
formData.add("return_session","0");
formData.add("session_key_only","0");
formData.add("trynum","2");
System.out.println(formData.toString());
WebResource resource = client.resource("https://www.facebook.com/login.php?login_attempt=1");
// for GET
//ClientResponse response = resource.type("application/x-www-form-urlencoded").get(ClientResponse.class);
Builder builder = resource.type("application/x-www-form-urlencoded");
// for POST
ClientResponse response = resource.queryParams(formData).post(ClientResponse.class, formData);
//ClientResponse response = resource.type("application/x-www-form-urlencoded").post(ClientResponse.class, formData);
String en = response.getEntity(String.class);
System.out.println(en);
System.out.println("oks");
}
}
Wednesday, September 7, 2011
Apache Clustering
http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html
http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html
http://tomcat.apache.org/tomcat-3.2-doc/tomcat-apache-howto.html
http://tomcat.apache.org/tomcat-5.5-doc/cluster-howto.html
http://tomcat.apache.org/tomcat-3.2-doc/tomcat-apache-howto.html
Friday, April 22, 2011
Oracle Application Framework - just Basics
Oracle Application Framework (OAF) facilitates consultants (both Technical and Functional) to cater to the daily requirements of their clients by enabling them to personalize, customize, extend and also develop new OAF pages and embed the same back into Oracle Applications. By using OA Framework a developer can:
create new OAF pages
personalize the pages
customize the existing (seeded) pages
extend the existing (seeded) pages
to meet variuos business needs.
to meet variuos business needs.
So what's the basic difference between personalization, customization, extension and development
1. Personalization: With this you can alter or tailor the look and feel of pages e.g. you can change the label of a text box, you can hide or show a component based on the logged in user or at the responsibility level or at site level itself.
2. Customization: Using this you can add the business logic to the already existing controller code e.g. suppose that you want to add one more validation at the click of some button.
3. Extension: Extension means that you are using the already existing functionality and also adding some more of yours e.g. you want to add some more where conditions to a seeded View Object (VO) query.
4. Development: Using development you can create new OAF pages and embed the same to Oracle Apps Instance to cater to the business needs of the clients.
Now depending upon the layout, complexity and business needs an OAF page can be built up by one or many regions. Region is a part of a page which acts as a container for the items or components. By default the top most level of a page has to be of the type "pageLayout" region type.
1. Personalization: With this you can alter or tailor the look and feel of pages e.g. you can change the label of a text box, you can hide or show a component based on the logged in user or at the responsibility level or at site level itself.
2. Customization: Using this you can add the business logic to the already existing controller code e.g. suppose that you want to add one more validation at the click of some button.
3. Extension: Extension means that you are using the already existing functionality and also adding some more of yours e.g. you want to add some more where conditions to a seeded View Object (VO) query.
4. Development: Using development you can create new OAF pages and embed the same to Oracle Apps Instance to cater to the business needs of the clients.
Now depending upon the layout, complexity and business needs an OAF page can be built up by one or many regions. Region is a part of a page which acts as a container for the items or components. By default the top most level of a page has to be of the type "pageLayout" region type.
Thursday, April 14, 2011
MySQL DB Table DESC to Excel Sheet Export
java code :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tabledescription;
import java.io.FileWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.io.IOException;
import java.io.File;
import jxl.Range;
import jxl.Workbook;
import jxl.format.UnderlineStyle;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
/**
*
* @author yogi
*/
public class Main {
public static void main(String[] args) throws IOException {
Connection connection = null;
WritableWorkbook workbook = Workbook.createWorkbook(new File("D:/my.xls"));
WritableSheet sheet = workbook.createSheet("mySheet", 0);
WritableFont arial10font = new WritableFont(WritableFont.ARIAL, 12, WritableFont.BOLD, false, UnderlineStyle.SINGLE, jxl.format.Colour.BROWN);
WritableCellFormat arial10format = new WritableCellFormat(arial10font);
WritableFont detailfont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
WritableCellFormat detailformat = new WritableCellFormat(detailfont);
WritableFont Headerfont = new WritableFont(WritableFont.ARIAL, 11, WritableFont.BOLD, false, UnderlineStyle.DOUBLE_ACCOUNTING, jxl.format.Colour.BLUE_GREY);
WritableCellFormat Headerformat = new WritableCellFormat(Headerfont);
FileWriter fw = new FileWriter(new File("D:/my.csv"));
fw.write("asdf");
fw.close();
try {
// Load the JDBC driver
String driverName = "com.mysql.jdbc.Driver"; // MySQL MM JDBC driver
Class.forName(driverName);
// Create a connection to the database
String serverName = "localhost";
String mydatabase = "mysql";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
String username = "root";
String password = "";
connection = DriverManager.getConnection(url, username, password);
Statement statment = connection.createStatement();
ResultSet resultSet = statment.executeQuery("show tables");
resultSet.next();
int j = 0;
while (resultSet.isLast() != true) {
Range range = sheet.mergeCells(0, j, 5, 0);
Label label = new Label(0, j, resultSet.getString(1), arial10format);
sheet.addCell(label);
System.out.println("Tables : " + resultSet.getString(1));
Statement statment1 = connection.createStatement();
ResultSet resultSet1 = statment1.executeQuery("desc " + resultSet.getString(1));
ResultSetMetaData RSM1 = resultSet1.getMetaData();
/* Label label8 = new Label(1, j + 1, "Field", Headerformat);
sheet.addCell(label8);
label8 = new Label(2, j + 1, "Type", Headerformat);
sheet.addCell(label8);
label8 = new Label(3, j + 1, "Null", Headerformat);
sheet.addCell(label8);
*/
resultSet1.next();
while (resultSet1.isLast() != true) {
int k = j++;
for (int i = 1; i <= RSM1.getColumnCount(); i++) {
Label label1 = new Label(i, k++, resultSet1.getString(i), detailformat);
sheet.addCell(label1);
System.out.print(resultSet1.getString(i) + " - ");
}
System.out.println();
resultSet1.next();
}
resultSet.next();
}
workbook.write();
workbook.close();
} catch (Exception e) {
System.out.println("Error : " + e);
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tabledescription;
import java.io.FileWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.io.IOException;
import java.io.File;
import jxl.Range;
import jxl.Workbook;
import jxl.format.UnderlineStyle;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
/**
*
* @author yogi
*/
public class Main {
public static void main(String[] args) throws IOException {
Connection connection = null;
WritableWorkbook workbook = Workbook.createWorkbook(new File("D:/my.xls"));
WritableSheet sheet = workbook.createSheet("mySheet", 0);
WritableFont arial10font = new WritableFont(WritableFont.ARIAL, 12, WritableFont.BOLD, false, UnderlineStyle.SINGLE, jxl.format.Colour.BROWN);
WritableCellFormat arial10format = new WritableCellFormat(arial10font);
WritableFont detailfont = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
WritableCellFormat detailformat = new WritableCellFormat(detailfont);
WritableFont Headerfont = new WritableFont(WritableFont.ARIAL, 11, WritableFont.BOLD, false, UnderlineStyle.DOUBLE_ACCOUNTING, jxl.format.Colour.BLUE_GREY);
WritableCellFormat Headerformat = new WritableCellFormat(Headerfont);
FileWriter fw = new FileWriter(new File("D:/my.csv"));
fw.write("asdf");
fw.close();
try {
// Load the JDBC driver
String driverName = "com.mysql.jdbc.Driver"; // MySQL MM JDBC driver
Class.forName(driverName);
// Create a connection to the database
String serverName = "localhost";
String mydatabase = "mysql";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
String username = "root";
String password = "";
connection = DriverManager.getConnection(url, username, password);
Statement statment = connection.createStatement();
ResultSet resultSet = statment.executeQuery("show tables");
resultSet.next();
int j = 0;
while (resultSet.isLast() != true) {
Range range = sheet.mergeCells(0, j, 5, 0);
Label label = new Label(0, j, resultSet.getString(1), arial10format);
sheet.addCell(label);
System.out.println("Tables : " + resultSet.getString(1));
Statement statment1 = connection.createStatement();
ResultSet resultSet1 = statment1.executeQuery("desc " + resultSet.getString(1));
ResultSetMetaData RSM1 = resultSet1.getMetaData();
/* Label label8 = new Label(1, j + 1, "Field", Headerformat);
sheet.addCell(label8);
label8 = new Label(2, j + 1, "Type", Headerformat);
sheet.addCell(label8);
label8 = new Label(3, j + 1, "Null", Headerformat);
sheet.addCell(label8);
*/
resultSet1.next();
while (resultSet1.isLast() != true) {
int k = j++;
for (int i = 1; i <= RSM1.getColumnCount(); i++) {
Label label1 = new Label(i, k++, resultSet1.getString(i), detailformat);
sheet.addCell(label1);
System.out.print(resultSet1.getString(i) + " - ");
}
System.out.println();
resultSet1.next();
}
resultSet.next();
}
workbook.write();
workbook.close();
} catch (Exception e) {
System.out.println("Error : " + e);
}
}
}
Wednesday, April 13, 2011
Create Apache,s Projects Structure using ANT
1 . create bat file
2. create script file (*.XML)
3. put the src folder with above 2 file.
4. put WebPages folder at same location.
5. Command to create War file : ant -buildfile <buildfilename.xml>
------------------------------------------------------------------------------------------
<?xml version="1.0" ?>
<project name="AntExample1" default="war" >
<path id="compile.classpath" >
<fileset dir="WebPages/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="MakeDirectory">
<mkdir dir="classes"/>
</target>
<target name="compile" depends="MakeDirectory">
<javac srcdir="src" destdir="classes" includeantruntime="false" >
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="war" depends="compile">
<war destfile="jarfile\AntExample.war" webxml="WebPages\WEB-INF\web.xml">
<lib dir="WebPages/WEB-INF/lib"/>
<classes dir="classes"/>
<fileset dir="WebPages"/>
</war>
</target>
</project>
2. create script file (*.XML)
3. put the src folder with above 2 file.
4. put WebPages folder at same location.
5. Command to create War file : ant -buildfile <buildfilename.xml>
------------------------------------------------------------------------------------------
<?xml version="1.0" ?>
<project name="AntExample1" default="war" >
<path id="compile.classpath" >
<fileset dir="WebPages/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="MakeDirectory">
<mkdir dir="classes"/>
</target>
<target name="compile" depends="MakeDirectory">
<javac srcdir="src" destdir="classes" includeantruntime="false" >
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="war" depends="compile">
<war destfile="jarfile\AntExample.war" webxml="WebPages\WEB-INF\web.xml">
<lib dir="WebPages/WEB-INF/lib"/>
<classes dir="classes"/>
<fileset dir="WebPages"/>
</war>
</target>
</project>
Subscribe to:
Posts (Atom)