Tuesday, June 19, 2012

tibrvsend to different subnet

The below example will explain you, how to send the message to different subnet.

Let  a network Bcast Address : 192.168.180.255
                              System IP  : 192.168.180.15
                             Host Name : tiger100
                   RVD service port : 7190


Another Network Bcast Address: 192.168.175.255
                             System IP       :192.168.175.51
                             Host Name     : lion100
                       RVD service port : 5991

Here we are going to send the message from tiger100 to lion100

1) check on both system if rvd process is running or not. It should running . else start rvd on both
    
    ps -ef | grep 'rvd'

2) Start the rvd listener on lion100

./tibrvlisten -service 7190  -daemon tcp:7500 Test.message

3) Now send the message from tiger100

./tibrvsend -network ";;192.168.175.51" -service 7190 -daemon tcp:7500 Test.message "Hello World"

That it... Now you the message at lion100.

Friday, June 1, 2012

File.executable? does not in this environment and will return a dummy value

 warning: executable? does not in this environment and will return a dummy value

I face this warning in java5 when executing command in system("command/shell script"). as the system usually check if the shell script is executable or not.

and java5 is required anyway for my application . So did the below changes to avoid the warning.

Before : system("shell Script")
After : output=`#{command}`

Tuesday, May 29, 2012

Global variable in Ruby/JRuby

If anybody wants to create a global variable which can be access to all the ruby class and module through out the project. then follow the example given below:

$globalvariable=

class
   .
   .
   .

end


The value of the globalvariale can be access through out the ruby project.

i.e. puts($globalvariable)

NOTE: "$globalvariable=value" may be display as $globalvariable= . it is a Bug with Blogger. So read it as  "$globalvariable=value"

Monday, May 28, 2012

Log Redirection in Ruby

If you wan to redirect your methods log to a file instead of console and after writing the log to the file the output should back to console then follow the below instructions.

def example()
 oldout=$stdout
 $stdout=File.new("",'a')
.
.
.                   
.
.
$stdout=oldout
end


you can change the type of writing to log file with replace of 'w', 'w+' etc.. depends on your requirements.

Monday, April 16, 2012

Module Example in Ruby Language

The below given example guide you , how to work with ruby module.

1) The ruby module are just like ruby class , which can contain the methods , fields etc..
2) Multiple modules can possible in a file , lets take an example :

create a file testModule.rb , create it any where does not matter. In side the file create the module viz.
here we have created two modules

1)Test
2)Test1

Test contains a simple method as show , So that we can call this method just by using the object of the used class of this module Test

Test1 contains the same method , but the declaration is bit different that is Test1.show . which behaves like a static method, and you have to call this method using the Module name i.e.

"Test1.show" -----------------------------------------------------------------------------------------------------------
File :  testModule.rb
------------------------------------------------------------------------------------------------------------

module Test
    def show
        print "From method Show"
    end
end

module Test1
     def Test1.show
         print " From Method Show from Module Test1"
     end
end

------------------------------------------------------------------------------------------------

Now create another ruby file for ruby class , let demo.rb
------------------------------------------------------------------------------------------------
require File.dirname("File path ")+"/ testModule"

class Demo
include Test
include Test1

   def  demoMethod
      print " from demoMethod"
       Test1.show
   end

end

test=Demo.new
test.demoMethod
test.show


Description : "require" is the keyword which is similar to include and import in c/c++ and java

The required keyword search for the file from $LOAD_PATH , if not not found , there would be a error as file not found, So in this case you can give the file path name followed by the file name.

Test1.demo is just similar as static method call using class name reference in java

If the module name is not used before the method name at the time of defining it, then that method can be called using the used call object. here in the above example it is Demo and test is the object of the Demo class.


Tuesday, March 20, 2012

Tutorials on ruby

The most intresting language after java is ruby , may be something more than java. Honestly I do not want to hurt the java developer anyway. Here is a below sample program which will give you a sample IDEA of ruby language. It is really a pure object oriented language.

class TestClass
 @@fname=""
 @@lname=""
 @@val="Bhubaneswar"
 
 def initialize(fname,lname)
  @fname=fname
  @lname=lname
 end

 def testMethod(val)
  puts("Inside the Method")
  puts("The Global Value is '#{@fname}' and '#{@lname}'")
  @val=val
  puts("The Local Value is '#{@val}'")
  puts("The Local Value is '#{@@val}'")
 end
end
obj=TestClass.new("khirod","Patra")
obj.testMethod("Delhi")


Description: TestClass is the name of the class must be stared with a capital letter. @@fname,@@lname,@@val are the class variable. The class variab;e declared with @@ symbol and the instance variable declared with single @ symbol. In the method testMethod you can see the instance variable i.e. @val . So if you want to access the class variable or the instance variable , you have to prefix with @@ or @ symbol with variable name, Incase if you have same variable name

Questions are welcome...

Friday, November 12, 2010

Tips on Virtual Box

If you are using any Virtual box , then you mustt add your user name to the vboxgusers group, So that you get access to the USB system in Windows XP i.e.

usermod -A vboxusers