Welcome to my website. I am always posting links to photo albums, art, technology and other creations. Everything that you will see on my numerous personal sites is powered by the formVistaTM Website Management Engine.


  • Subscribe to this RSS Feed
  • Splitting a String into an Array with a Custom Delimiter in a Bash Shell Script
    08/20/2013 12:27PM

    Most high level languages have some sort of String.split([delimiter]) method to create an array of Strings tokenized by a user specified delimiter.  This is a simple way to convert a CSV into an array.

    Here is a quick way to do that in a bash shell script:



    # Save the initial Interal Field Separator

    # Set the IFS to a custom delimiter

    read -a TOKENS <<< "${SOURCE_STRING}"

    for i in "${TOKENS[@]}"
       echo "$i"

    # Reset original IFS

  • Running VisualVM to Examine a JVM on a Remote Host Via an SSH Tunnel/Proxy Connection
    07/12/2013 11:21AM
    VisualVM is a great tool for peering into a running JVM.  In many cases, it won't be one that is running on your local box.

    The first thing to be done is to get jstatd running on the remote machine:

    Create a security policy file on the remote machine (this assumes that you have an additional layer of security and that the outside world cannot access these ports and/or you have a VPN set-up and you are operating in that enclave):

    $ cd ~

    $ more jstatd.all.policy

    grant codebase "file:${java.home}/../lib/tools.jar" {

       permission java.security.AllPermission;


    Next run jstatd on the remote machine:

    $ jstatd -J-Djava.security.policy=/fully/qualified/path/to/jstatd.all.policy

    On the local machine set up an SSH connection through which you will tunnel your VisualVM connection:

    $ ssh -D localhost:9696 rchapin@remote.machine.to.proxy.to

    On the local machine fire up jvisualvm

    $ jvisualvm

    Go to:  Tools > Options > Network:

    Check 'Manual proxy settings':
    Add localhost and port 9696 to the SOCKS Proxy setting
    Under the Applications Tab, Right-click on 'Remote' and select 'Add Remote Host'

    Add the remote user name or ip (if you are running the RMI registry on a different port select Advanced and configure as necessary).

    Once added the remote JVMs that are running as the same user as your local user will be displayed and you can connect to them as normal
  • Setting up an HTTP Proxy over SSH in Chrome under Fedora Core 18 Linux
    07/12/2013 10:15AM

    At least under the FC 18 distro, there was no fancy GUI controls in the Advanced Settings for setting up an HTTP proxy over SSH for Chrome.

    To get it all set up:

    • Establish and ssh connection to the server to which you want to proxy:
      • $ ssh -D localhost:1234 username@remote.server,  where 1234 is the port number you want to use for the proxy
    • Run google-chrome from the command line passing it the proxy setting:
      • $ google-chrome --proxy-server=socks5://localhost:1234
  • Screen Cheat Sheet
    06/12/2013 8:08AM

    I have recently be introduced to the *nix screen command.  Incredibly powerful tool for managing windows which mulitplexes a physical terminal between one or many processes.  One of the uses it to maintain interactive shells on a remote server between remote connections to the machine.

     It is enormously helpful when executing long running commands on remote servers.  Especially those that timeout your ssh connection and or from machines that you are going to either disconnect from the net or shutdown.

    Basically, it allows you to create a session from which you can detach and then attach from a shell that you will then exit.  It is an alternative for using nohup and provides the added benefit that you can reconnect to the command-line session.

    Following is my current cheat sheet of notes regarding it's usage.  Full details can be found searching the web for tutorials and reading the man page.

    -- Legend

    . C-a = Control+A
    . C-D = Control+D
    -- Commands

    . Create a screen:
    $ screen -S [session-name]

    . Detach from screen:
    $ C-a d

    .  Terminate a screen session (from within the screen session):
    $ C-a k

    . List screens (from within a standard shell session):
    $ screen -ls

    . Connect to an existing screen:
    $ screen -r [session-name]

    . If there is only one screen and no session-name is given it will connect to it

    . Re-connect to an 'attached' screen:  This sometimes happen if you kill the window you are in without first detaching from the screen session
    $ screen -d -r [session-name]

    . Split screens:

    . Create two named screen sessions:

    . Enter one of the screens via $ screen -r [session-name]

    . Horizontal split (once in a screen):
    $ C-a S

    . Move to next region:
    $ C-a tab
    . In the new region, (there will be no command prompt in a newly created region)
    . Create a new session (this seems to create a new un-named session):
    . C-a c

    . Return to full-size screen:
    . Switch to the half you want to keep
    . $ C-a Q
  • Quick and Dirty HTTP Server to Transfer Files
    06/06/2013 10:50AM

    If you need to stand up a quick HTTP Server to enable someone on your LAN to transfer some files use the following command in the directory that you want to 'share':

    python -m SimpleHTTPServer

    The default port is 8000, but you can run it as follows to specify a port

    python -m SimpleHTTPServer 8080

Advanced Search