Tuesday, August 5, 2008

Change VC++ Win App to Console App

To change the windows application in Visual C++ to console after change the name of WinMain method to another name to prevent the linker to set it as entry point and add a main method you may get the error:
LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

So you need another change in your project properties:
Project Properties -> Linker -> System -> SubSystem

and set it to
Console (/SUBSYSTEM:CONSOLE)

rather than
Windows (/SUBSYSTEM:WINDOWS)

That suggested to the linker that maybe the program entry point should be “main” rather than “WinMain

Monday, August 4, 2008

Run Java Application using Server JVM

Every form of Sun's Java runtime comes with both the "client VM" and the "server VM." Unfortunately, Java applications and applets run by default in the client VM. The Server VM is much faster than the Client VM, but it has the downside of taking around 10% longer to start up, and it uses more memory.

There are two ways to run Java applications with the server VM:

1. When launching a Java application from the command line, use java -server [arguments...] instead of java [arguments...]. For example, use java -server -jar beanshell.jar.

2. Modify the jvm.cfg file in your Java installation. (It's a text file, so you can use Notepad or Emacs to edit it.) This is located in C:\Program Files\Java\j2reXXX\lib\i386\ on Windows, /usr/java/j2reXXX/lib/i386/ on Linux. You will see two lines:

-client KNOWN
-server KNOWN

You should change them to:

-server KNOWN
-client KNOWN

This change will cause the server VM to be run for all applications, unless they are run with the -client argument.

Saturday, August 2, 2008

Solaris Log Files

  • /var/adm/syslog -- Logs common system events
  • /var/adm/messages -- Miscellaneous log file for most events on a system
  • /var/cron/log -- Logs all jobs run in crontab
  • /var/lp/logs/lpsched -- Logs information related to the print services
  • /var/adm/pacct -- Used for process accounting

Tuesday, July 29, 2008

Scripting Oracle SQL

To run sql commands of oracle in a script to use abilities of it like scheduling with crontab write the shell script commands in script.sh as belows

script.sh:
FILENAME=$(date +'%d-%m-%Y.txt')
sqlplus user/pass@db-sid <<EOL >> $FILENAME
select * from tbl1 where rownum<10000;
EOL

If sqlplus can't be run in the context of the this user the above script can be called in another script with su -c or specifying oracle user in crontab.

Monday, May 19, 2008

Delete Duplicate Rows in Oracle

DELETE FROM our_table
WHERE rowid not in
(SELECT MIN(rowid)
FROM our_table
GROUP BY column1, column2, column3... ;

Wednesday, May 14, 2008

Sun Volume Maintenance

1- Check volumes by metastat to see is there a mirror or submirror which contains not OK state(Last Erred|Needs Maintenance|Resyncing) like below:
metastat d5
d25: Submirror of d5
State: Resyncing
Size: 8395200 blocks
Stripe 0:
Device Start Block Dbase State Hot Spare
c1t1d0s5 0 No Resyncing

2- Check disk needs maintenance with format analyze or fsck commands.

3- If error repaired re-enable submirror with metareplace command:
metareplace -e d5 c1t1d0s5

after the command, submirror state change to Resyncing and if there is no hard error it will become OK.
Complete Help @ Sun

Tuesday, May 13, 2008

Microsoft Mary, Mike and Sam Voice SAPI 5.0

To install additional voice for Microsoft Text to Speech 5.0 (TTS) download and install the following package from Microsoft:
http://download.microsoft.com/download/speechSDK/SDK/5.1/WXP/EN-US/speechsdk51.exe

If the engine is not installed download engine 5.1 and install this first:
https://www.cepstral.com/downloads/public/other/SAPI_5.1_installer.msi

Microsoft Mary, Mike and Sam Voice SAPI 5.0

To install additional voice for Microsoft Text to Speech 5.0 (TTS) download and install the following package from Microsoft:
http://download.microsoft.com/download/speechSDK/SDK/5.1/WXP/EN-US/speechsdk51.exe

If the engine is not installed download engine 5.1 and install this first:
https://www.cepstral.com/downloads/public/other/SAPI_5.1_installer.msi

Monday, April 21, 2008

Remove Unix User Expiry Date

To remove expiry date of a user's password the following command can be used:
usermod -e "" username
The command will change shadow file, not manually. The value of parameter -e can be a date to set a new expiry date.

Sunday, April 13, 2008

.rhosts and remote login

To allow a username can be used for remote login and tools like rcp, in the home directory of that user should add a file .rhosts and add the trusted host name or ip in that. To allow all host can use + char.

A point should be considered is that the permissions of the owner of this file should be set. (chmod [700, 600,500,400] .rhosts).
-rwx------ 1 user1 other 20 Apr 13 17:39 .rhosts

Another file that is used by system to remote access after checking of .rhosts is /etc/hosts.equiv. Each recored line in this file contain hostname [username], means which user from which machine can access without password to this machine. Same as previous file + char can be used to indicate all host or/and all users.

Attend to this point that user is local user that exist in /etc/passwd of
server machine.

Saturday, April 12, 2008

Unix Change Timezone & Cron Job

To change timzone in unix should set and export TZ variable
TZ=IRST-4:30
format of this variable value depends on platform.

The file /etc/TIMEZONE should be chnaged to reflex settings after reboot.

after changing the timezone cron task should be restarted to apply new timezone information,
/etc/init.d/cron stop
/etc/init.d/cron start

or kill /usr/bin/cron task and start it again.

Tuesday, April 8, 2008

Internal Causes of Call release in Siemens IN 7b

1 = unallocated (unassigned) number
2 = no route to specified transit network
3 = no route to destination
4 = send special information tone
5 = misdialled trunk prefix
6 = TCAP-Cause: missing customer record
16 = normal call clearing
17 = user busy
18 = no user responding
19 = no answer from user (user alerted)
21 = call rejected
22 = number changed
27 = destination out of order
28 = address incomplete
29 = facility rejected
31 = normal – unspecified
34 = no circuit available
38 = network out of order
41 = temporary failure
42 = switching equipment congestion
44 = requested channel not available
47 = resource unavailable – unspecified
50 = requested facility not subscribed

55 = incoming calls barred within CUG
57 = bearer capability not authorized
58 = bearer capability not presently available
63 = service/option not available – unspecified
65 = bearer capability not implemented
69 = requested facility not implemented
70 = only restricted information bearer capability is available
79 = service or option not implemented – unspecified
87 = called user not member of CUG
88 = incompatible destination
91 = invalid transit network selection
95 = invalid message, unspecified
97 = message type non-existent or not implemented
99 = par. non-existent or not implemented – discarded
103 = par. non-existent or not implemented – passed on
111 = protocol error, unspecified
127 = interworking, unspecified

Sunday, April 6, 2008

Swap VoMS Application or Database Cluster

If we want to switch Siemens VoMSXpress application from one machine to another it's use scswitch command. Be informed this configuration uses Sun Cluster technology, in other technology such as Veritas it should be different.

1- chris application should be stopped and when starting the framework should run as last application
(/opt/xpress/SxFramework/scripts/Sx.sh SxFrameWork stop|start)

2- check sun cluster status
scstat
The status of cluster, like which app or db on which cluster, online or offline

Node name Status
--------- ------
Cluster node: voms1 Online
Cluster node: voms2 Online

3- Stop appropriate resource group
scswitch -F -g [rg_sxfwapp|rg_sxfwdb] (-F make offline)

4- Change primary node
scswitch -z -D [appvol|dbvol] -h [voms2|voms1] (-z change primary node)

5- Make resource online
scswitch -Z -g [rg_sxfwapp|rg_sxfwdb] (-Z make resources online)

6- Start chris application as mentioned above

Thursday, April 3, 2008

Sending Double Message in Dialogic Sigtran

The problem of sending 2 or more message once you send 1 message from top of stack pretending to sctp. In new version of host software package(5.05) a new configuration command -CNTOS- is supported to setup timing for sctp and m2pa.

To prevent sending more than one same message the retransmission configuration of both side must be same. In dialogic side it's done by CNTOS command and RMIN(retransmission min) and RMAX(retransmission max) parameters. In cisco itp side can be seen by sh cs7 m3ua command.

Windows XP Timezone and Daylight Saving

Some useful information and a good tool to configure proper daylight saving configuration for windows:

http://support.microsoft.com/kb/914387

TZEdit can edit time zone information.

Tuesday, February 19, 2008

Solaris Network Configuration

View current configuration of all interfaces:
/usr/sbin/ifconfig -a

Configure network card and enable it in hardware level
ifconfig eth0 plumb

Assign ip and mask to interface
ifconfig eth0 192.168.100.12 broadcast 192.168.100.255 netmask 255.255.255.0

Uping the interface to work
ifconfig eth0 up

all commands together
ifconfig eth0 192.168.100.12 broadcast 192.168.100.255 netmask 255.255.255.0 plumb up

Check other hosts addressing for interfaces
arp -a

Assign default boot-time IP to interfaces by inserting ip address in proper hostname file
/etc/hostname.eth0 or /etc/hostname.qfe2
The postfix period (eth0) depends on device driver and number of that type.

Mapping names to IP is set in /etc/hosts
www.name1 192.168.10.10
www.name2 172.168.10.25

Setting defult gateway to act as router by inserting gateway address in /etc/defaultrouter

To set ip address of an interface by DHCP at boot-time proper hosname.*** file should be empty and another empty file, /etc/dhcp.*** , should be created.

Connect VPN Command Line

In Windows XP:
rasdial conName userName passWord
rasdial conName /DISCONNECT

Monday, February 18, 2008

Format SQLPlus Output

set linesize 100
set newpage 0
set pagesize 999

Format number column:
col[umn] colName for[mat] 999..number of digits..99

charachter:
col[umn] colName for[mat] a(length of string)

Wednesday, February 6, 2008

VPN and LAN Together

To prevent normal routing of packets in main connection after connecting new connection like vpn, should disable use default gateway on remote network on vpn connection properties->Networking->IP Properties->General Advanced, and to enable routing of packets of vpn to appropriate destination add the following to the route table:

route add dest-addresses mask dest-addr-mask gateway-ip
route add 192.168.0.0 mask 255.255.0.0 192.168.100.120

Wednesday, January 30, 2008

Presenting of Point Code in SCCP Called Party

The way to set Present of PC in Called and Calling Party of SCCP layer in dialogic host software is setting ext_options of SCCP_Config command which is 16 MSB of 32bits option parameter.
Presence of PC in CDPA is equal to set bit #2.

SCCP_CONFIG 10278 0x8 0x00020102 0x00000001

Detail of setting these bits is discussed on SCCP Programmers Manual, ext_options section.

Sunday, January 27, 2008

Cisco Telnet Session Timeout

line vty 0 4
-->exec-timeout 5 0 // Session will be disconected after 5 min of inactivity
-->logout-warning 60 //Warning timeout before automatically logoff
-->absolute-timeout 15 //After 15 min router wil disconnect telnet session


Sunday, January 20, 2008

Change Structure Member Alignmment

To change memory alignment in VC++ or diable it(set it to 1 byte) use /Zp[num] (num 1,2,4,8,16) in compiler command line or set it through ProjProp->C/C++->Code generation->Struct Member Alignment

Thursday, January 17, 2008

Randomization

srand(time(0)); // for seed based on current time

int k = 1 + rand() % 80; // for random number 1 to 80

Monday, January 14, 2008

Start & Stop IN Application

In Siemens IN classic 7b, we can stop and start only SCP application with the following commands, without any need to restart SCP machine:
stop: mkup -dtK
start: mkup -rstK

*These command have to be run in instscp user context.
** The first application which comes up will become the master counter manager.

Other useful command in this subject:
Check Up & Down of process on local and remote hosts
mkup -iploc
mkup -iprem

Check master and slave Counter Manager
cmctx_ls -l

Wednesday, January 9, 2008

Unsigned Primitive Type in Java

1- You can use Javalution.org packages to use unsigned types.

2- Converting unsigned types to standard java types:
byte b;
int i = b & 0xff;

int i;
long l = i & 0xffffffffL;

3- Combining two unsigned shorts into an unsigned int.
short ush = 4;
short
usl = 9999;
int
ucombined = ( ush & 0xffff ) << 16 | ( usl & 0xffff );

4-/**
* Convert an unsigned int to a String.
* @param i the int to convert.
* @return the equivalent unsigned String
*/
public static void unsignedToString( int i )
{
return Long.toString( i & 0xffffffffL )
}