Disk Partitioner for KDE4

(Sunday, May 3, 2009)

KDE 4.22

If you are looking for gparted for KDE, or qtparted for KDE:

Look for "partitionmanager"

Kubuntu:

sudo apt-get install partitionmanager


Fedora:
su
yum install partitionmanager


-Tres

Posted in 0 comments Posted by FatButtLarry at 11:02 AM

Send Escape Keystroke To Telnet With Java

(Tuesday, April 28, 2009)

I had a very hard time trying to figure out how to send "CTRL+A" to a Telent session through Java. (for an AS/400 telnet session).


First obstacle was finding what the key mapping was. I found this on midrange.com. "CTRL+A maps to "Escape, A". [link]

Using TelnetWrapper library here: [link]
I found the Escape Key value here: [link]

What confused me at first was the use of the word "Escape" in the Telnet specification. There are special escaped keys that would normally use the TelnetProtocolHandler's sendTelnetControl(byte code) function. This is not the case. Here's how I did it:

TelnetWrapper t = new TelnetWrapper();
t.connect(hst, prt);
t.waitfor("User . . . . . . . . . . . . . .");
t.send(user + "\t" + pwd);
byte[] b = new byte[] {'\033', 'a'};
t.write(b);
System.out.println(t.waitfor(""));

-Tres

Posted in 0 comments Posted by FatButtLarry at 8:27 AM

Swap Alt + Command Key Ubuntu

(Wednesday, April 15, 2009)

For Gnome Users:
System --> Preferences --> Keyboard
Layouts Tab --> Layout Options
Alt/Win Key Behavior --> Left Alt is swapped with Left Win


For KDE 4.x Users:
System Settings --> Regional and Language
Keyboard Layout --> Layout Tab --> Enable Keyboard Layouts
Advanced Tab --> Alt/Win key behavior --> Left Alt is swapped with Left Win


This will swap your ALT key with the WINDOWS key (also called "Super", "Apple" or "Command"). This is useful for a person who Alt+Tab's on a PC but has since switched to macintosh hardware and is not accustomed to the Macintosh keyboard layout.

If you are not using a macintosh keyboard, this *should* have the opposite effect and make a PC keyboard ALT+TAB like a Mac.

I never thought to look in the locale settings for KDE, so this took me quite a while to find. Hope it helps others.

This works on Ubuntu 8.10, Ubuntu 9.04, Kubuntu 9.04. (Intrepid, Jaunty). This should work for both KDE and gnome respectively. Hope this saves some people some time.

-Tres

Posted in Labels: , , , , , , , , , , , , , , , , , 0 comments Posted by FatButtLarry at 3:59 PM

5 Silk Icons

(Thursday, April 9, 2009)

I've used FamFamFam's CreativeCommons Silk icon set for a while and I've made a few of my own. Here they are for others to share, hosted on Blogger/Picasa and mirrored on ImageShack.

  • [mirror] Lotus Domino Server Silk Icon (server_lotus.png)
  • [mirror] Windows Active Directory Server Silk Icon (server_windows.png)
  • [mirror] iSeries As/400 Server Silk Icon (server_as400.png)
  • [mirror] Microsoft Office Visio Silk Icon (page_white_visio.png)
  • [mirror] Microsoft Office InfoPath Silk Icon (page_white_infopath.png)

-Tres




-Tres

Posted in Labels: , , , , , , , 0 comments Posted by FatButtLarry at 5:35 AM

NetBeans CellRenderer JTable

(Wednesday, April 8, 2009)

I am trying to assign a setDefaultCellRenderer(..., ...) to my NetBeans projects and all of the answers keep steering me back to "Table Contents --> Columns --> Renderer" and then I am stuck.

I was working from this guide and quickly noticed it had no effect on my NetBeans JTable!!! I've been using this guide in non-NetBeans projects with success, but now using the NetBeans IDE it fails. Am I doing something wrong?

First of all, there's quite a few people asking this same question:

http://forums.netbeans.org/post-871.html
http://www.netbeansforum.com/viewtopic.php?f=4&t=26
http://www.nabble.com/JTable-With-ComboBox-(list)-td15324201.html
http://www.nabble.com/Cell-renderer-editor-in-Netbeans--td18043645.html
http://www.nabble.com/TableCellRenderer-in-netbeans.-td8238826.html#a8240804
http://www.coderanch.com/t/345011/Swing-AWT-SWT-JFace/java/Customize-JTable-NetBeans-GUI-Builder


This quick article shed some light on the class types, but chaning my setDefaultRenderer(..., ...) to "String.class" didn't fix it.
http://www.devx.com/tips/Tip/15851

So I've updated the nabble post with some of my attempts. No answers yet. Any help appreciated:
http://www.nabble.com/Cell-renderer-editor-in-Netbeans--td18043645.html

-Tres

Posted in 0 comments Posted by FatButtLarry at 8:04 AM

Descriptor index not valid

(Monday, April 6, 2009)

"java.sql.SQLException: Descriptor index not valid."


If you are running an SQL query (in this case with Java) against an AS/400 and get the above message, try replacing the code in your resultset loop. Find the line that looks like this:
rs.getString(0)
And replace with lines like this:

rs.getString("PFNMCN");

Notice, the records is being retrieved by name instead of by index. Alternately, you can try:

rs.getString(1);


The underlying problem is resultset indexes start at [1] instead of [0]. This is confusing as most Java indexes start counting at 0. Hope this helps. What the message should probably say is "resultset index is out of bounds for the returned set". But jt400 is a free driver, so we can live with that message. :)

Also note, that if you do "SELECT PFNMCN AS FIRSTNAME...", then your code should read:

rs.getString("FIRSTNAME");

This java error message can be confusing at first, but it is a very quick fix!

-Tres

Posted in Labels: , , , , , , , , , 0 comments Posted by FatButtLarry at 11:50 AM

Java, Telnet and AIX

(Tuesday, February 24, 2009)

I've decided to use the UnixLoginHanlder class. Here's my sample code s, and below is the history of my struggles.

Socket s = new Socket(host, port);
UnixLoginHandler handler = new UnixLoginHandler(s);
TelnetInputStreamConsumer is = handler.doLogin(user, pass);

String command="echo hello > deleteme.tres\r\n";

pw = new PrintWriter(new OutputStreamWriter(s.getOutputStream()), true);

pw.print(command);
// Don't forget to flush

pw.flush();

// Executing these immediately may precede the commands.
// Do logout/disconnects on a seperate event
//handler.doLogout();

//handler.disconnect();

Good luck!

____________________________________________________________
____________________________________________________________

This article will illustrate my struggles with automating some Telnet functions through Java. The application that's being designed could provide as an interface or relay server, and is intended eventually to get some information out of some flat files on an IBM AIX Unix server.

Disclaimer: Yes I'm aware of the security issues around the Telnet protocol. No, SSH is not available currently on this server.

In short, I'm trying to get a simple telnet session working through a Java Socket connection. Some examples, like this one make it seem as simple as making a new Socket and sending some text through. Naturally, I wouldn't be writing this article if it were that simple. Methods like "readline()" return arbitrary characters like "ÿþ%ÿý", and there's not much documentation around what this all means, so instead of spending more time re-inventing the wheel, I've begun evaluating 3rd party APIs.

A quick Google search shows some APIs with tutorials, but costs money. I'm skipping those for now, since I'm just in the design phase of this interface, so I'm sticking to free ones for now. The closer to GPL the better, right?

Forums allude that the Apache project has a great implementation of the Telnet protocol. My experience with the Apache libraries are they are often interdependent on each other, and I'd like to make this interface as small and vanilla as possible. I've found three potential candidates: JTA Telnet for Java, sadun-utils UnixLoginHandler and Dieter Wimberger's telnetd2. Telnetd2 does not come pre-compiled to drop-in as an API and also doesn't provide any code-snippets or documentation with its download, so going to skip that for now as well.

My unsuccessful code snippets are below attached exactly as they appeared in outgoing emails. As authors respond, I'll post their messages as well. If I have success, I'll certainly post that too.

Hi.

My name's Tres and I've been trying to use JTA as an API in an
application for implementing a simple Telnet connection.

I tried the sample code in /jta26/de/mud/telnet/
TelnetWrapper's
javadoc, and it connects and does a log-in first try, however I'm
having a hard time getting any further, such as executing commands on
the remote host.

I'm in Windows XP JDK 1.6 connecting to AIX 5.2. If I run the JAR as
an application it works just like PuTTY and acts as expected, so I'm
sure its something that I'm doing wrong in the code.

Is there a mailing list or perhaps a person to contact with this?
Also, are there any special considerations when connecting to Korn
shell or AIX? Thanks!

-Tres

p.s. I've attached the sample TelnetWrapper code below which has been
copied from the javadoc.

/**
* TelnetWrapper telnet = new TelnetWrapper();
* try {
* telnet.connect(args[0], 23);
* telnet.login("user", "password");
* telnet.setPrompt("user@host");
* telnet.waitfor("Terminal type?");
* telnet.send("dumb");
* System.out.println(telnet.
send("ls -l"));
* } catch(java.io.IOException e) {
* e.printStackTrace();
* }
*/
I quickly received a response from Matt Jugel:
Check that there actually is a "Terminal type?" prompt coming from your AIX host.
It will wait forever if this is not prompted. Remove the Terminal type waitfor and the send lin thereafter and try again.

Leo.
And here's my response to him:
Matt,

Thanks for the quick response. I simply attached that for a
refresher. A snippet of my usage is attached below. My "output" from
the command is always "null" and the file "deleteme.tres" never gets
created.

> TelnetWrapper telnet = new TelnetWrapper();
> String output;
> try {
> telnet.setLocalEcho(true);
> System.out.println("
Connecting...");
> telnet.connect(host, port);
> System.out.println("Logging in...");
> telnet.login(user, pass);
> System.out.println("Waiting...
");
> telnet.waitfor("/usr/local/
gnu/bin");
> System.out.println("Sending command...");
> output = telnet.send("echo hello > deleteme.tres");
> System.out.println("Output: " + output);
> telnet.disconnect();
> System.out.println("Done.");
> }
> catch(java.io.IOException e) {
> e.printStackTrace();
> }


-Tres

I've since emailed sadun through the SourceForge website on the UnixLoginHandler API:

Hi,

My name's Tres and I'm trying to set up a simple Telent session to an AIX machine. Client is Windows XP JDK 1.5 server is AIX 5.2.

I've tried your API for establishing this connection, and it seems to log in just fine, but when I try sending commands to the server, it does not appear to be working. Here's a snippet of my code:

> Socket s = new Socket(host, port);
> UnixLoginHandler handler = new UnixLoginHandler(s);
> TelnetInputStreamConsumer is = handler.doLogin(user, pass);
> String command="echo hello > deleteme.tres";
> pw = new PrintWriter(new OutputStreamWriter(s.getOutputStream()), true);
> pw.print(command+"\r\n");
> handler.doLogout();

When I do a "who" on the server, I can see the specified user logging in as a TTY session, however, the command does not appear to be executing, as the file "deleteme.tres" never gets created.

Any help would be appreciated. Sorry to email you through SourceForge, but I couldn't find a forum for this project.

-Tres
Sadun replied quickly with the following:
Hei,

no problem. Unfortunately I dont have an AIX machine to test right now. The original code's been running over HP and Solaris insofar I know.
How does the login prompt looks like at your target host? The handler uses "ogin:" by default, but it may be need to be configured differently.

Of course a bug is always possible. Like most of the utility classes, the group of telnet-related classes are relatively self contained - it should be easy to download the source and check directly at least where the output ends up stopping with a step-by-step editor..

-cs
And here's my response to him:
cs,

Thanks for the quick response.

The login sequence is working great. The server I am connecting to
uses "login:", and
"Password:". It appears to be logging in correctly as I can see the
connection come through (see screenshot "telnet.png" attached).

I am using the org.sadun.util.jar on my class path, so I cannot
step-by-step into the source code at this moment.

Could the issue be the CRLF characters sent through the terminal? Can
these change? I'm confused because the login works as expected.

To add to the confusion, I am having identical issues with JTA -
Telnet/SSH libraries where the connection establishes but I cannot go
any further.

Any help is greatly appreciated!!

-Tres
Here's his most useful response:
Hm. Have you tried removing the wrapping PrintWriter and flushing the outputstream directly?
Flush being the keyword. Since I had not worked with OutputStreams, I had forgotten to flush(), and the code snippet didn't have this line in there. Kudos to the UnixLoginHandler. This will the the one I'll use.

-Tres

Posted in 2 comments Posted by FatButtLarry at 7:38 PM