Friday, March 11, 2011

PVCS - Source repository File Server

In PVCS, when we try to open the project database, it typically lists File Servers to select. The file server name listed there is not the actual server's name. Recently, we had to find out what server it was connecting to. This can be done in Admin->File Servers menu option in PVCS. You can add/delete/update server names here.

[caption id="attachment_4952" align="alignnone" width="300"]pvcs_server_list Where to add PVCS server list[/caption]

So, if the PVCS server is changed in the future and you need to connect to the new server, change it as mentioned above. This needs to be done on each developer machine or the ini file could be distributed. (The name of the ini file is, C:\Program Files\Merant\vm\common\bin\win32\servers.ini)

[caption id="attachment_4951" align="alignnone" width="300"]PVCS Servers Fig 2. server list is stored in servers.ini[/caption]

If you connect to PVCS from Powerbuilder (or any other MSSCCI compliant IDEs), you do not have to change anything there. PB actually reads the PVCS servers.ini file to get the PVCS Server name(s). After making the changes to File Server name in PVCS, we just need to disconnect and reconnect to merant version manager in Powerbuilder.

SQLPLUS - Spooling in HTML format

I used this recently and I thought of sharing this. If you don't know this already, SQL*PLUS has built in support for HTML. All you have to do is add markup option either on command line or inside the script. By the nature of it, it is only useful when you are spooling the output. Useful when you are dumping from multiple tables or generating simple reports. Just be aware that the output file will be larger than the usual text file spool.

Just add below to the script before spooling and the

SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON -
HEAD "<TITLE>E-App Validation Report</TITLE> -
<STYLE type='text/css'> -
<!-- BODY {background: #FFFFFF} --> -
</STYLE>" -
BODY "TEXT='#000FF'" -
TABLE "WIDTH='90%' BORDER='5'"

spool cleanup_eapp_data.html

SQLPlus - spool name with embedded timestamp

To be able to create a spool file, with filename embedded with timestamp:

— spool filename with timestamp
col sysdt noprint new_value sysdt_var
SELECT TO_CHAR(SYSDATE, ‘yyyymmdd_hh24miss’) sysdt FROM DUAL;
spool run_filename_&sysdt_var.Log

Update 12/07/12

This was confusing, as I had the same name for column name and the SQL variable created by new_value. I've renamed the two accordingly. This works.

Also, I posted about spooling to HTML some time back. You can combine the two, of course:

col spoolname new_value spoolname_var

select 'tablist_'||to_char(sysdate, 'yymmdd_hh24miss') || '.html' spoolname from dual;
prompt &spoolname_var

SET MARKUP HTML ON -
HEAD "<TITLE>Session Stats</TITLE> -
<STYLE type='text/css'> -
<!-- BODY {background: #FFFFFF} --> -
</STYLE>" -
BODY "TEXT='#000FF'" -
TABLE "WIDTH='90%' BORDER='5'"

spool &spoolname_var

SELECT username, logon_time, status FROM v$session;
spool OFF;

creates a nice HTML file with a list of all users currently logged on to the database. This is saved in a HTML file with timestamp in it's name!

Thursday, March 10, 2011

TomCat + Sybase EA Server

Today another coworker of mine was trying to get XAMPP setup work with our EA Server. (We have PB application and Java objects deployed to this EA Server). He has a complete setup of XAMPP with Apache and Tomcat. He has a JSP page that uses the PB objects. This got to a point and crashed with "class not found" error. Clearly pointing to a classpath issue. But which one?

He mentioned that he had to set the EA Server first before he started XAMPP. Clearly there are some conflicts in the classes shared between the 2. EA Server is normally started using a batch file that reads the env classpath (windows settings in control panel) and adds its own classpaths locally. (SET LOCAL inside batch file). So whatever EA Server set is not visible to XAMPP but not the other way around. That's why he had to start EA Server first.

We then looked for the specific class that was "not found". This happened to a stub for the PB objects. In Jaguar manager (aka Sybase Central, EA Server admin) there is an option to generate stubs (and skeletons if needed). This typically points to SYBASEEASERVERHTMLCLASSES directory. We found out that he also similar classes in SYBASEEASERVERJAVACLASSES directory. We knew these were not used, as they were not in the class path. Then we searched for classes or jar files with similar names. We stumbled on a jar file that contains part of these stubs, inside XAMPP. (He uses OpenBD for coldfusion applications, which is why he has XAMPP in the first place). This jar was old and had part of the stubs classes and did not have the one we were having trouble with.

Apparently Tomcat was automatically loading this jar (Anything inside the lib directory gets loaded automatically). We found that when we tried to rename the file.

Now that we found out the classes in trouble, we thought we could just add the class paths needed to the environment classpath and hope Tomcat would pick it up. This did not happen. On the web, I saw a note about how Tomcat handles classpaths differently than regular Java. There was a suggestion to the classpath to the batch file that starts Tomcat. We didn't try that yet.

For now, we decided to copy the classes to the library folder, so Tomcat can automatically load the classes. So, we shut down XAMPP, regenerated the jar file (in EA Server stub generation, there is an option to generate a jar instead of class files) and copied to XAMPP lib folder and everything worked OK.

Wednesday, March 9, 2011

Linux: Wget, Yum

One of my co-workers was trying to install Oracle linux update to Fedora linux box. She was trying to do a wget command based on some web site instructions. Her wget failed and was not able to get the repository file at public-yum.oracle.com.

wget http://public-yum.oracle.com/public-yum-ol6.repo

Per suggestions on the web, we tried using host or nslookup for the website. They could not find the web site.

Where as, google site was always found. host google.com and nslookup google.com worked fine. But not to the oracle server. Not even oracle.com showed up when we tried host, nslookup and ping commands.

After googling it up and trying to find solutions, we got to a point, where it pointed to some kind of network issue, probably proxy? I asked her to download the above file manually (she was always able to go to the web page directly in browser) and save to /etc/yum.repos.d directory. Then we tried,

yum list command.

This gave a different error:

IOError: <urlopen error (-2, 'Name or service not known')>

Some more web searches (http://serverfault.com/questions/76421/wget-cant-resolve-host) revealed this to be related to DNS. That was kind of strange. As we were able to ping and nslookup to google.com and we were always able to go to the oracle site in browser.

Anyways, we decided to edit the /etc/resolve.conf file and add some public name servers to it.

nameserver <dns ip address>

This didn't help. Then she logged into a unix box and we looked at the /etc/resolve.conf there. It had only one name server. We copied to the file on Linux box. Bingo!! It worked. So, the problem was that the name servers she had listed in the resolve file didn't resolve oracle servers for some reason.

Yum, Wget etc

I really didn't know much about Yum and Wget until today. While working on this problem, learned a few things:

Wget is a cool utility to download files. Per the wikipedia page , wget (formerly geturl) is a non-interactive replacement for FTP, but it also works with other protocols like HTTP, HTTPS etc. It can download recursively.

Yum is a package manager/installer for Linux. See here for a definition:

http://www.wisegeek.com/what-is-yum.htm

Turns out the .repo file we were having problem with in the first place, is the repository that has some configurations to be used by Yum to download more files and install them.

Note: If you are editing any of the /etc/ files and you already have the console window open, chances the new settings will not be effective. Close all the console windows and start a new one.

Sunday, February 13, 2011

ubuntu & I

I've a long experience with the Unix world. When I first picked up Linux, it was all command line (I think it was Redhat). I kept hearing about it and I noticed that it's commands overlapped with Unix shells in many ways. I told myself, yeah I know Linux. This was more than 10 years ago.

Since then I've had chances to work on Linux command line versions several times when I worked on some web projects in PHP/MYSQL. Still the same impression. It's like Unix.

Few years ago, I was at Fry's. They had a PC for $125+. This was when a decent windows PC cost like $500 - $1000. I was thrilled. Picked up one and took it home. It had some flavor of Linux on it. To my surprise, it had a windowing version of Linux. I was thrilled. I took out my windows PC (I believe Win2K or XP) and plugged in the new PC. I connected to Ethernet, mouse, keyboard, speaker, monitor and even the printer. To my surprise Internet connected right away. So did the monitor, keyboard, mouse. After some fiddling I was able to get sound working also. I've worked with windows and experienced the typical windows problems like driver issues, software issues, hardware incompatibility issues before. Different versions of windows didn't work with the same hardware. Here I got a totally strange Operating System (Actually it was strange because the flavor of Linux I had was from Taiwan and it printed a lot of Chinese characters - that added to my surprise as well) and it worked like a charm. I was impressed. But, I didn't keep the PC for long, as there some other devices that failed with it.

Till recently It's been touch and go with Linux. Recently, my windows PC crashed. I must admit, I installed EASUS partitioning software and some registry compacter and these screwed up a lot of paths in the registry. I tried to restore from Restore points, alas it wouldn't. I tried to create one, it failed. I had to actually reinstall windows from the backup that comes with HP PC. This was frustrating experience. My PC had been slower and slower, which is what drove to touch the partition and registry in the first place. Now that I reinstalled windows, I was hoping my PC was going to perform better. To my disappointment, it really didn't.

My father was visiting me and in his spare he decided to build a PC. I had different old PC's hanging around. He got one working by replacing the motherboard with Intel Atom based board. It has a memory restriction of 1GB. We got an old Windows XP drive installed and was actually run Windows. (Not quite easily though - Windows seems to build configuration of the PC where it was first installed, so when I tried to use XP in a different PC, it failed to boot). I didn't remember the windows password. After looking around, we found a Linux based password extraction program!!! The entire operating system on a CD and we didn't even have to install it. It ran right out of the CD.

This is when we decided to give Ubuntu a shot. I eventually installed Ubuntu. The windowing interface it had, blew me away. I loved it. And as usual, the PC with Linux worked with all the devices right out of the box. Actually the Windows on the Atom PC did have problem with Audio and to my surprise, Audio worked with Ubuntu.

Then I dusted off an old 10GB drive and installed Ubuntu on it. Now, this is my main PC. Ever since, I am hooked to Ubuntu. Everyday I keep discovering new software to install and still have some more space to do other things. So far, this older PC with less memory and hard disk space than my 2-year old Windows Vista PC, the run for the money. Now, I don't use my Windows PC directly. When I want to I remote desktop from my Ubuntu PC.

I have plans to upgrade my Ubuntu PC. (I don't have the intention to get rid of Windows PC yet, as there are several software on it that I still use). But, with Wine installed, I am discovering new sides of Linux. I will write more about my experience with Linux here.

Monday, November 22, 2010

Script: PB backup – Using PB ORCA to export PBLs

A basic Operating system level unit in Powerbuilder is a library file (.PBL). Each PBL file is a self contained directory in itself, with the objects stored inside in a proprietary binary format. You need Powerbuilder to view and work with this directory structure (System tree, Library painter etc).

Sometimes, it would be nice to be able to work with individual objects as text files at the OS level. This will enable us to use any text utilities to work with the objects as files (like you would a Java or C++ file). For e.g., I have a Perl script to grep through the exported text files. With text files, you can store away these source files in any version control systems (PVCS, SVN etc) easily. And you can easily diff 2 versions of an object by using any text diff tool (Of course, there are tools available to do these from inside PB, but it's just lot easier to work text files). PB allows the source code to be exported to text files with extensions, *.sr? (.srw for windows, .srd for datawindows etc.).

PB ORCA is an API that Powersoft developed early on for 3rd Party CASE tool vendors to work with PB objects. With PB ORCA, you can write programs to work PB libraries and objects from OS command line. Several object level operations available in PB IDE are also available in this API. Incidentally, there is a command line utility available with the same name (pborca.exe) on Google Code. The tool has several commands that correspond to API functions. You can create a ORCA script file (with .orc extension) and run it in batch mode using the tool. See here for a complete list of commands supported by the tool.

Below script uses pborca.exe in a DOS batch file to export all the objects in all the PBLs in a project directory to a corresponding directory structure. The batch file first loops on a list of .pbl files in a directory (passed in), and creates an ORCA script (latax.orc) with export commands. Then it runs the generated ORCA script using pborca.exe to export the object files (.*sr?). When the script finishes, you will have directory with several sub-directories, one for each PBL file exported.

This script uses several advanced features (%~ modifiers, ENABLEDELAYEDEXPANSION) of DOS Batch file. DOS scripts do several things a Unix script does, but it’s almost like an after thought! More on these later.

I use this script for daily backup of my development environment. Often times only a handful of files change on the developer's PC. Once I export the PBLs to a directory, I can diff 2 different versions using a diff tool. (I use Winmerge). The files can be optionally zipped up as well.

Pborca.exe can also handle the reverse (known as bootstrapping). Exported PB object files are only useful for performing file level operations. To be useful in a PB application, they will have to be imported back in to a PBL file again which can then be opened inside Powerbuilder. As of version 9, PB ORCA can be used to bootstrap as well. See here for the idea.

REM 12,2009 Sam V
REM script to export PBLS using pborca.exe (ORCA interface to PB)
REM this copies all the folders from source (typically Z:) to target.
REM then it creates an ORCA script to export each pbl to the subdirectories.
REM Finally it runs the generated orca script in pborca
REM @echo off

echo %0 %1, %2
@REM copy all the directories from the powerbuilder root to the export directory
@REM if a x.PBL is already in x subdirectory, you may not need MKD1 below.

@echo creating the target directory; just copy the entire path with empty sub-directories
xcopy /t /e /I %1 %2

@REM Here we start generating the orca file to be used with <a href="http://pborca.googlecode.com/svn/trunk/install/deploy/pborca.htm">PBORCA</a>.
@echo session begin pborc100.dll > latax.orc

@echo off
@SETLOCAL ENABLEDELAYEDEXPANSION
@FOR /f "usebackq delims=" %%a IN (`dir /s /b %1*.pbl`) DO (
@set a1=%%~dpa
@REM echo a1=%a1%
@call set "a1=!a1:%~1=%~2!"
@REM MKD1
@REM This creates a sub-directory with the same name as PBL file
mkdir "!a1!"
@echo export %%~fa,,,!a1! >> latax.orc)

@echo session end >> latax.orc

@ENDLOCAL

@echo on
@echo run the script in pborca
pborca latax.orc

REM end of script