Ruby scripts & launchd

I have writting a ruby script for use by launchd. The script runs fine on it on without launchd and been tested several times on several items. However, when loaded by launchd it gives an error and exits. Here is the launchd plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.avicenna.webloc2url</string>
<key>LowPriorityIO</key>
<true/>
<key>Program</key>
<string>/Users/avicenna/Library/Scripts/webloc2url.rb</string>
<key>ProgramArguments</key>
<array>
<string>webloc2url.rb</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Users/avicenna/Downloads/Bookmarks</string>
</array>
</dict>
</plist>
and here is the syslog error:
Nov 26 15:35:13 avicenna com. avicenna.webloc2url[17236]: nil
Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: /Users/avicenna/Library/Scripts/webloc2url.rb:10
Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: : private method `sub!' called for nil:NilClass (NoMethodError)
Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: from /Users/avicenna/Library/Scripts/webloc2url.rb:4:in `each'
Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: from /Users/avicenna/Library/Scripts/webloc2url.rb:4
Nov 26 15:35:38 avicenna com. avicenna.webloc2url[17243]: nil
Nov 26 15:35:38 avicenna com.apple.launchd[132] (com. avicenna.webloc2url[17243]): Exited with exit code: 1
regarding the error:
private method `sub!' called for nil:NilClass (NoMethodError)
the stand alone script never complains about such an error, actually it does the substitution and prints what is expected. In fact, the script does the job well. So, this makes me think that there might be some limitation on the execution of ruby scripts by launchd? Or maybe the parameters I've put in the plist file are not correct or missing something?
Any kind of help or hint would be appreciated.
Thanks.

jarik, thanks and sorry if I bothered you. I have made little changes in the script and I don't see any complains in the system.log anymore. Here is the script with the changes:
#!/usr/bin/env ruby
Dir.chdir("/Users/avicenna/Downloads/Bookmarks")
d = Dir.new("/Users/avicenna/Downloads/Bookmarks/")
d.each do |x|
if x =~ /webloc/
y = `strings '#{x}'/..namedfork/rsrc`.chomp.detect { |v| v =~ /http/ }
webloc = File.open("#{x}", 'r+')
webloc.puts "[InternetShortcut]\nURL" + y.sub!(/^./, '=')
#puts y
webloc.close
oldFile = x
newFile = x.sub(/webloc/, 'url')
File.rename(oldFile, newFile)
end
end
I've added the .chomp as you can notice and the substitution changed to '=' from the preceeding string instead of an empty ''. I hope this will fix it for good. And I don't know exactly what did that change anyway for launchd!
Thanks again.

Similar Messages

  • Ruby Script as FCS response

    I want to execute a ruby script as a FCS response attached with a poll watcher. But it is throwing following error again and again,
    response Asset MOS Registration script triggered by Watcher New Asset Watcher failed
    response failed to run command ruby /usr/local/bin/hw.rb with arguments { geobit }
    ERROR: E_COM
    Comnmand exited with status 1
    How can I execute a ruby script as FCS response. Please help?
    http://pk.linkedin.com/in/subhanmughal
    http://subhan-mughal.blogspot.com/

    There is nothing magical you need to do to call a Ruby script from FCSvr - it runs as any other command line script does.
    Make sure you are escaping the command line arguments properly, that the fcsvr process calling it has permissions to access the areas you may call in your script, and that paths are also set appropriately.

  • Thought I would share: Ruby script to control USB dart launchers

    Been hacking away at this for a bit and I'm calling this good for now   This script controls USB dart launchers like this guy:
    0a81:0701 Chesen Electronics Corp. USB Missile Launcher
    At the moment, it's coded to only control the above, but add your idVendor, idProduct, and movement codes to the ActionData hash and it should pick right up and work.
    Requires the libusb and curses gems.  Codepad: http://codepad.org/v9h3ziYw
    Enjoy!
    #!/usr/bin/env ruby
    Version = '0.1'
    abort("Usage: #{__FILE__} idVendor:idProduct") if ARGV.empty?
    require 'curses'
    require 'libusb'
    # Add your own idVendor, idProduct, and movement codes here!
    ActionData = {
    :idVendor => 0x0a81,
    :idProduct => 0x0701
    } => {
    :up => 0x02,
    :down => 0x01,
    :left => 0x04,
    :right => 0x08,
    :fire => 0x10,
    :stop => 0x20,
    class RocketLauncher
    attr_accessor :device
    def move(symbol)
    @usb.control_transfer(
    :bmRequestType => 0x21,
    :bRequest => 0x09,
    :wValue => 0x0000,
    :wIndex => 0x0000,
    :dataOut => ActionData[{
    :idVendor => device[:idVendor],
    :idProduct => device[:idProduct]
    }][symbol].chr
    end
    def start
    begin
    @usb = LIBUSB::Context.new.devices(
    :idVendor => device[:idVendor],
    :idProduct => device[:idProduct]
    ).first.open.claim_interface(0)
    rescue LIBUSB::ERROR_ACCESS
    abort("No permission to access USB device!")
    rescue LIBUSB::ERROR_BUSY
    abort("The USB device is busy!")
    rescue NoMethodError
    abort("Could not find USB device!")
    end
    Curses.noecho
    Curses.init_screen
    Curses.stdscr.keypad(true)
    Curses.timeout = 150
    Curses.addstr("USB Rocket Launcher Controller v#{Version} by Maxwell Pray")
    loop do
    Curses.setpos(2,0)
    case Curses.getch
    when Curses::Key::UP, 'w', 'W'
    Curses.addstr("Movement: Up!")
    self.move(:up)
    when Curses::Key::DOWN, 's', 'S'
    Curses.addstr("Movement: Down!")
    self.move(:down)
    when Curses::Key::LEFT, 'a', 'A'
    Curses.addstr("Movement: Left!")
    self.move(:left)
    when Curses::Key::RIGHT, 'd', 'D'
    Curses.addstr("Movement: Right!")
    self.move(:right)
    when Curses::Key::ENTER, 10, ' '
    Curses.addstr("Movement: Fire!")
    self.move(:fire)
    when 27, 'q', 'Q'
    exit
    else
    Curses.addstr("Waiting for key...")
    self.move(:stop)
    end
    Curses.clrtoeol
    end
    end
    end
    launcher = RocketLauncher.new
    device = ARGV[0].split(':').map { |id| id.to_i(base=16) }
    launcher.device = {
    :idVendor => device[0],
    :idProduct => device[1]
    launcher.start

    problem fixed with method
    detach_kernel_driver
    thx ^^
    but now there is no FIRE action with enter Action is active, but:
    :fire  => 0x10
    does nothing.
    Where i can find any info about this? Maybe it must be another for my device?

  • [solved] ruby script do not work (in arch)

    Hi!
    I want to change my csv blinklist exported data to a html bookmarks format (to import it to delicious)
    I installed ruby, and used this script: http://rubenlaguna.com/wp/2010/01/03/mi … v-to-html/
    but it shows this error:
    $ ruby change.rub
    /usr/lib/ruby/1.9.1/csv.rb:1329:in `initialize': can't convert String into Integer (TypeError)
            from /usr/lib/ruby/1.9.1/csv.rb:1329:in `open'
            from /usr/lib/ruby/1.9.1/csv.rb:1329:in `open'
            from change.rub:18:in `block in <main>'
            from change.rub:6:in `open'
            from change.rub:6:in `<main>'
    the csv file looks like this:
    http://pastebin.ca/1737483
    any idea what is wrong?
    friends, that do not uses arch, tested it and it worked in their machines...
    Last edited by luuuciano (2010-01-04 19:15:35)

    Hi, the problem is that Arch Linux uses the newer Ruby 1.9.x version which is incompatible with that script. I have tried to fix the script for you, it seems to work but I don't even know what delicious is so you'll have to just try it and see
    http://pastebin.ca/1737706

  • Ruby Script API or documentation

    Hello,
    can I use the full scope of ruby in the UI-Designer?
    If not, is there any documentation of functionality (create new associations...etc.)?
    Best regards,
    Andreas

    Hi,
    the Ruby used in scripting ("SAP Ruby") is NOT a complete implementation of Ruby. It is just a scripting language with a syntax similar to Ruby.
    Documentation of the UI designer and scripting is planned for FP2.6 but is not yet available.
    For the time being we have some How tos in the following Wiki page 
    [https://www.sme.sap.com/irj/sme/community/collaboration/wiki?path=/display/AMI/BestPracticefor+Implementations]
    to show some working examples. If an example is missing, please let us know. We will then enhance the collection.
    Regards,
    Thomas
    Backoffice Early Partner Program

  • HTML generator script (in Ruby) - what do yout think about it?

    Hi folks,
    since I have a lot of time recently, I decided to create a little (non-dynamic) website with HTML and CSS.
    So, when I began writing I noticed that there is a lot of "typing overhead" what really went on my nerves.
    Be it as this may... I was thinking about how I could shorten the whole process of writing HTML-code.
    I began writing a little ruby-script, wich reads a HTML file line by line, searches for a certain pattern, interprets this pattern and generates HTML-code out of it.
    I hope you get what I mean. Here is the code (it's still experimental... )
    # Command class - contains the "template"-code
    class Commands
    # generate a list
    def Commands.list(args)
    s = "<ul>\n"
    args.each { |arg| s += "<li>#{arg}</li>\n" }
    s += "</ul>\n"
    end
    # generate a headline
    def Commands.h2 (args)
    "<h2>#{args.join(" ")}</h2>"
    end
    # generate an image
    def Commands.img(args)
    "<img src='#{args[0]}' width='#{args[1]}' height='#{args[2]}'/>"
    end
    end
    # Searches for pattern and executes them
    def execute_rubyfoo(content)
    content = content.map { |line| line.strip }
    new_content = content
    success = 0
    errors = 0
    puts "Generating..."
    new_content.each_with_index { |line, i|
    # line matches pattern
    if line =~ /^\$\$\s*rfoo.*/
    command = new_content[i].sub(/\$\$rfoo\s*/, "")
    command = command.sub(/\s*\$\$/, "")
    command = command.split(" ")
    begin
    method = Commands.method(command[0])
    new_content[i] = method.call command[1..-1]
    success += 1
    rescue NameError => e
    puts "--> Line #{i + 1}: Command not found: #{command[0]}"
    errors += 1
    end
    end
    puts "\n---"
    puts "Finished: #{success} successfully, #{errors} errors."
    new_content
    end
    file = File.new("foo.html", "r+")
    new_content = execute_rubyfoo(file.readlines)
    file.close
    new_file = File.new("foo.html.bla", "w+")
    new_file.puts new_content
    new_file.close
    An example HTML-file could look like that:
    <html>
    <body>
    <h1>Hallo</h1>
    $$rfoo list 1 2 3 4 5$$
    $$rfoo h2$$
    $$rfoo img bla.png 100 100$$
    </body>
    </html>
    And a generated HTML-file like that:
    <html>
    <body>
    <h1>Hallo</h1>
    <ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    </ul>
    <h2>foo</h2>
    <img src='bla.png' width='100' height='100'/>
    </body>
    </html>
    So, now what I want to know is:
    What do you think about this idea in general and the way I implemented it? Is there already something like that?
    Thanks,
    g0ju

    ERB is even part of the standard ruby libraries. See the Notes for other alternatives.
    I have to admit that I'm guilty of reinventing that wheel, too
    Last edited by hbekel (2009-09-22 09:04:57)

  • [SOLVED]Ruby on Rails won't run with apache/passenger

    Hi I want to run Redmine, a Ruby on Rails application, on a personal server using MariaDB as the database and Apache with the Phusion Passenger module as the application platform. So far I am able to run Redmine with the default WeBrick server, but if I try to run it via Apache (http://192.168.1.5/redmine) I just get the directory index of  /usr/share/webapps/redmine. I've been running various php webapps using this apache installation without issues but my unfamiliarity with Ruby on Rails makes me unsure how to fix this. If I create a Ruby on Rails test  application as described at https://wiki.archlinux.org/index.php/Ru … figuration I get the same issue.
    Using the arch wiki articles on Ruby on Rails and Redmine, This is basically how I installed things:
    $ yaourt -S ruby1.9 rubygems1.9 nodejs redmine
    # gem-1.9 install rails
    # gem-1.9 install passenger
    /opt/ruby-1-9/ and subfolders ended up having no read/exexute permissions for 'other', probably because of my umask settings, so I changed the permissions, also because apache runs as user/group 'apache'.
    Ran the script that installs the passenger apache module:
    # /opt/ruby1.9/bin/passenger-install-apache2-module
    added to httpd.conf:
    LoadModule passenger_module /opt/ruby1.9/lib/ruby/gems/1.9.1/gems/passenger-4.0.5/libout/apache2/mod_passenger.so
    PassengerRoot /opt/ruby1.9/lib/ruby/gems/1.9.1/gems/passenger-4.0.5
    PassengerDefaultRuby /opt/ruby1.9/bin/ruby
    ServerName arch-server
    DocumentRoot /usr/share/webapps
    <Directory "/usr/share/webapps">
    # This relaxes Apache security settings.
    AllowOverride all
    Order allow,deny
    Allow from all
    # MultiViews must be turned off.
    Options -MultiViews
    </Directory>
    I checked if the passenger module is loaded, and judging from /var/log/httpd/error_log that seems the case:
    [ 2013-07-03 22:52:22.8947 28902/b7407700 agents/Watchdog/Main.cpp:440 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nobody', 'default_python' => 'python', 'default_ruby' => '/opt/ruby1.9/bin/ruby', 'default_user' => 'nobody', 'log_level' => '0', 'max_instances_per_app' => '0', 'max_pool_size' => '6', 'passenger_root' => '/opt/ruby1.9/lib/ruby/gems/1.9.1/gems/passenger-4.0.5', 'pool_idle_time' => '300', 'temp_dir' => '/tmp', 'union_station_gateway_address' => 'gateway.unionstationapp.com', 'union_station_gateway_port' => '443', 'user_switching' => 'true', 'web_server_pid' => '28901', 'web_server_type' => 'apache', 'web_server_worker_gid' => '1001', 'web_server_worker_uid' => '1006' }
    [ 2013-07-03 22:52:22.9120 28905/b73bd700 agents/HelperAgent/Main.cpp:555 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.28901/generation-0/request
    [ 2013-07-03 22:52:22.9262 28902/b7407700 agents/Watchdog/Main.cpp:564 ]: All Phusion Passenger agents started!
    [ 2013-07-03 22:52:22.9266 28910/b71dd700 agents/LoggingAgent/Main.cpp:271 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.28901/generation-0/logging
    [Wed Jul 03 22:52:22 2013] [notice] Apache/2.2.24 (Unix) PHP/5.4.16 mod_ssl/2.2.24 OpenSSL/1.0.1e DAV/2 Phusion_Passenger/4.0.5 configured -- resuming normal operations
    'apachectl configtest' gives 'Syntax OK'.
    I followed the wiki on redmine (https://wiki.archlinux.org/index.php/Redmine), chose to use "bundle install" to install the required gems with only a 'production' environment. What worried me is that those gems are now in /root/.gems while the webserver runs as user 'apache'.
    I can run Redmine at 192.168.1.5:3000 without errors using:
    # ruby script/rails server webrick -e production
    But if I kill it and try via apache http://192.168.1.5/redmine I get a directory content listing.
    Last edited by rwd (2013-07-04 21:00:10)

    Thanks markocz, my use of sub-url was indeed the problem. With help from the linked article I did the following:
    # mkdir /usr/share/webapps/phusion-passenger/
    # ln -s /usr/share/webapps/redmine/public /usr/share/webapps/phusion-passenger/redmine
    # chown -R root:http /usr/share/webapps/
    # chmod -R g+rx /usr/share/webapps/
    httpd.conf now looks like this:
    LoadModule passenger_module /opt/ruby1.9/lib/ruby/gems/1.9.1/gems/passenger-4.0.5/libout/apache2/mod_passenger.so
    PassengerRoot /opt/ruby1.9/lib/ruby/gems/1.9.1/gems/passenger-4.0.5
    PassengerDefaultRuby /opt/ruby1.9/bin/ruby
    ServerName arch-server
    DocumentRoot /usr/share/webapps/phusion-passenger
    <Directory "/usr/share/webapps/phusion-passenger">
    # This relaxes Apache security settings.
    AllowOverride all
    Order allow,deny
    Allow from all
    # MultiViews must be turned off.
    Options +FollowSymLinks
    </Directory>
    RailsBaseURI /redmine
    <Directory "/usr/share/webapps/phusion-passenger/redmine">
    Options -MultiViews
    </Directory>
    Redmine now works via passenger.
    Last edited by rwd (2013-07-04 20:59:40)

  • Generating Ruby Web Service Access Classes from a WSDL

    If you have tried to consume a web service from Ruby you surely have noticed how annoying is to write manually all the Ruby code just to invoke a service with complext input parameters' structure:
    - You have to know what do the input parameters, their structure and type look like;
    - You have to write Ruby classes for them to encapsulate the structures;
    - You have to instantiate these classes and pass the objects to the web service proxy class;
    - You have to interprete the output parameters.
    All this is not impossible of course, but if you are just consumer of the web service and not the developer, if you don't have the exact documentation, you have to read the WSDL description of the service and create the Ruby classes (structures) for the parameters.
    Fortunately there is a small, though handy tool, called <b>wsdl2ruby.rb</b>. It accomplishes all these boring tasks for you.
    In the following example I will try to show you how <b>wsdl2ruby</b> can be used to generate Ruby classes for accessing a SAP NetWeaver web service, called <b>CreditChecker1</b> (a web service for checking if a person is reliable credit consumer).
    To generate the necessary classes we will create a ruby script. Let us name it <b>ws2rgen.rb</b>. Here is what this file looks like:
    # Import the wsdl2ruby library.
    require 'wsdl/soap/wsdl2ruby'
    require 'logger'
    # Callback function for the WSDL 2 Ruby generation options.
    def getWsdlOpt(s)
         optcmd= {}
         s << "Service"
         optcmd['classdef'] = s
         #should work but doesn't, driver name is derived from classname
         #if you specify both it breaks, same thing for client_skelton
         #optcmd['driver'] = s
         optcmd['driver'] = nil
         #optcmd['client_skelton'] = nil
         optcmd['force'] = true
         return optcmd
    end
    # Create logger.
    logger = Logger.new(STDERR)
    # Create WSDL2Ruby object and generate.
    worker = WSDL::SOAP::WSDL2Ruby.new
    worker.logger = logger
    # WSDL file location.
    worker.location = "http://mysapserver:53000/CreditChecker1/Config1?wsdl"
    # Where to generate.
    worker.basedir = "temp"
    # Set options.
    worker.opt.update(getWsdlOpt("Service"))
    # Heat.
    worker.run
    The procedure is straightforward. First we create the WSDL2Ruby object, set its properties <b>location</b> and <b>basedir</b> and then set all other options via the callback function <b>getWsdlOpt()</b>. For further information about these parameters one could consult the source code of wsdl2ruby or contact the developers. Nevertheless the default options are pretty satisfactory. With the last line we start the generation. Two Ruby files will be generated in the <b>temp</b> folder, which is a subfolder of the script's current folder. <b>Please, create the folder "temp" before executing the script.</b>
    This generates two files. The first one is <b>CreditChecker1Wsd.rb</b>, containing the necessary data structures:
    require 'xsd/qname'
    # {urn:CreditChecker1Vi}areReliable
    class AreReliable
      @@schema_type = "areReliable"
      @@schema_ns = "urn:CreditChecker1Vi"
      @@schema_qualified = "true"
      @@schema_element = [["persons", "ArrayOfPerson"]]
      attr_accessor :persons
      def initialize(persons = nil)
        @persons = persons
      end
    end
    # {urn:CreditChecker1Vi}areReliableResponse
    class AreReliableResponse
      @@schema_type = "areReliableResponse"
      @@schema_ns = "urn:CreditChecker1Vi"
      @@schema_qualified = "true"
      @@schema_element = [["response", ["ArrayOfboolean", XSD::QName.new("urn:CreditChecker1Vi", "Response")]]]
      def Response
        @response
      end
      def Response=(value)
        @response = value
      end
      def initialize(response = nil)
        @response = response
      end
    end
    # {urn:CreditChecker1Vi}isReliable
    class IsReliable
      @@schema_type = "isReliable"
      @@schema_ns = "urn:CreditChecker1Vi"
      @@schema_qualified = "true"
      @@schema_element = [["person", "Person"]]
      attr_accessor :person
      def initialize(person = nil)
        @person = person
      end
    end
    # {urn:CreditChecker1Vi}isReliableResponse
    class IsReliableResponse
      @@schema_type = "isReliableResponse"
      @@schema_ns = "urn:CreditChecker1Vi"
      @@schema_qualified = "true"
      @@schema_element = [["response", ["SOAP::SOAPBoolean", XSD::QName.new("urn:CreditChecker1Vi", "Response")]]]
      def Response
        @response
      end
      def Response=(value)
        @response = value
      end
      def initialize(response = nil)
        @response = response
      end
    end
    # {urn:java/lang}ArrayOfboolean
    class ArrayOfboolean < ::Array
      @@schema_type = "boolean"
      @@schema_ns = "http://www.w3.org/2001/XMLSchema"
      @@schema_element = [["boolean", ["SOAP::SOAPBoolean[]", XSD::QName.new("urn:java/lang", "boolean")]]]
    end
    # {urn:com.sap.scripting.test.services.creditchecker.classes}Person
    class Person
      @@schema_type = "Person"
      @@schema_ns = "urn:com.sap.scripting.test.services.creditchecker.classes"
      @@schema_element = [["age", "SOAP::SOAPInt"], ["name", "SOAP::SOAPString"], ["purse", "Purse"]]
      attr_accessor :age
      attr_accessor :name
      attr_accessor :purse
      def initialize(age = nil, name = nil, purse = nil)
        @age = age
        @name = name
        @purse = purse
      end
    end
    # {urn:com.sap.scripting.test.services.creditchecker.classes}Purse
    class Purse
      @@schema_type = "Purse"
      @@schema_ns = "urn:com.sap.scripting.test.services.creditchecker.classes"
      @@schema_element = [["color", "SOAP::SOAPString"], ["money", "Money"]]
      attr_accessor :color
      attr_accessor :money
      def initialize(color = nil, money = nil)
        @color = color
        @money = money
      end
    end
    # {urn:com.sap.scripting.test.services.creditchecker.classes}Money
    class Money
      @@schema_type = "Money"
      @@schema_ns = "urn:com.sap.scripting.test.services.creditchecker.classes"
      @@schema_element = [["amount", "SOAP::SOAPDouble"], ["currency", "SOAP::SOAPString"]]
      attr_accessor :amount
      attr_accessor :currency
      def initialize(amount = nil, currency = nil)
        @amount = amount
        @currency = currency
      end
    end
    # {urn:com.sap.scripting.test.services.creditchecker.classes}ArrayOfPerson
    class ArrayOfPerson < ::Array
      @@schema_type = "Person"
      @@schema_ns = "urn:com.sap.scripting.test.services.creditchecker.classes"
      @@schema_element = [["Person", ["Person[]", XSD::QName.new("urn:com.sap.scripting.test.services.creditchecker.classes", "Person")]]]
    end
    The second file is <b>CreditChecker1WsdDriver.rb</b>. In it you can find a generated child class of SOAP::RPC::Driver, containing all methods of this web service, so you don't need to add every method and its parameters to call the web service.
    require 'CreditChecker1Wsd.rb'
    require 'soap/rpc/driver'
    class CreditChecker1Vi_Document < ::SOAP::RPC::Driver
      DefaultEndpointUrl = "http://mysapserver:53000/CreditChecker1/Config1?style=document"
      MappingRegistry = ::SOAP::Mapping::Registry.new
      Methods = [
      def initialize(endpoint_url = nil)
        endpoint_url ||= DefaultEndpointUrl
        super(endpoint_url, nil)
        self.mapping_registry = MappingRegistry
        init_methods
      end
    private
      def init_methods
        Methods.each do |definitions|
          opt = definitions.last
          if opt[:request_style] == :document
            add_document_operation(*definitions)
          else
            add_rpc_operation(*definitions)
            qname = definitions[0]
            name = definitions[2]
            if qname.name != name and qname.name.capitalize == name.capitalize
              ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
                __send__(name, *arg)
              end
            end
          end
        end
      end
    end
    There is a problem with this script, since the <b>Methods</b> array is empty. I suppose it is due to the imports in the SAP NetWeaver WSDL, maybe wsdl2ruby is not mighty enough to handle these WSDL imports. When I succeed in overcoming this, I will post again in this thread to let everybody know.
    Message was edited by: Vasil Bachvarov

    Hi,
    I find Ruby to be really tough to consume SAP WebServices. For simple scenarios like currency conversion may it is good. But for complex scenarios such as Purchase Order entry etc..I found it very annoying to use wsdl2ruby and see that it didnt generate correct proxies.
    Until wsdl2ruby is stable enough to support complex datatypes, authentication etc. my recommendation is to use JRuby and use Java Proxies generated by NW Developer studio until pure Ruby's web service support improves.
    Following link might be of interest w.r.t wsdl2ruby
    http://derklammeraffe.blogspot.com/2006/08/working-with-wsdl2r-soap4r-and-complex.html
    Regards
    Kiran

  • Ruby and Mysql and Nmap

    I am trying to create a table name in a mysql database using ruby scripts. The name of the table should be the current date. this is how i tried to do it, but didnt work:
    in the ruby code:
    TOS = Time.now.localtime.strftime("%Y-%m-%d_#{Time.now.hour}:#{Time.now.min}")
    dbh = Mysql.real_connect("localhost", "testuser", "testpass", "test")
    dbh.query("CREATE TABLE #{TOS}
    IP VARCHAR(10),
    PORT VARCHAR(5),
    SERVICE VARCHAR(40)
    This doesnt work for some reason.. I started ruby yesterday so easy comments about my ignorance

    The article at http://developer.apple.com/tools/developonrailsleopard.html suggests updating Rails and installed gems.
    I ran the following:
    $ sudo gem update --system
    $ sudo gem install rails
    $ sudo gem update rake
    and all was well. Then I ran
    $sudo gem install mysql
    and got the following output.
    norbert:vocab bwelling$ sudo gem install mysql
    Building native extensions. This could take a while...
    ERROR: Error installing mysql:
    ERROR: Failed to build gem native extension.
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql
    can't find header files for ruby.
    Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7 for inspection.
    Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out
    norbert:vocab bwelling$
    Ideas??
    So... Something is jacked, that's for sure.

  • What is Wrong With This Script!?

    I've been trying to write a script to calculate the odds of getting a particular number when rolling a pair of 10-sided dice and adding them together.  The ruby script I've been trying to write simply does not work.  I don't know if I'm overlooking something or stumbled into a bug with the ruby interpreter.  Could someone take a look at it and tell me if anything's wrong?
    Here's the offending section of the script:
    $ary = Array.new(20, 0)
    $x, $y, $z = 0, 0, 0
    10.times do
    $x += 1
    10.times do
    $y += 1
    $z = $x + $y
    $ary[$z] += 1 #This is the line causing problems
    end
    end
    And here's the error message I'm getting:
    Dice.rb:9: undefined method `+' for nil:NilClass (NoMethodError)
    from Dice.rb:6:in `times'
    from Dice.rb:6
    from Dice.rb:4:in `times'
    from Dice.rb:4

    dtw wrote:You're also "wasting" 2 elements in your array as you will never get z = 0 or 1.  If these is an academic exercise i.e. you are doing it for practice not for purpose, you might consider creating a hash instead of an array with keys 2 through 20 to refer to each result.
    I was doing it for a purpose, but wasted elements are not a concern for me since this was just a script I would be using only once.  I'm in the process of designing a tabletop RPG.  One of the mechanics in the game is the use of 2d10, which are rolled for resolving actions.  I needed to know the odds, as they would affect the game mechanics.

  • WiFi script.

    Well I made a wifi script for myself because netcfg didn't like working and I was tired of my makeshift connect script. So I made this ruby script to help me learn and to have a useful connect script so I thought that others might find it useful.
    #!/usr/bin/ruby
    # kukri
    $help = <<HELP
    Kukri
    WiFi script by Dart27 <[email protected]>
    usage
    scriptname [interface]
    -s --scan Scans for access points.
    -c --connect SSID {Hexkey|s:asciikey} Connect to an access point
    -d --disconnect Disconnect from current access point
    -h --help Displays this help and exits
    -i --information Displays SSID and signal strength
    You can edit the source file to change the default interface and DHCP client.
    Note for wep users, if you are using an ascii key, prepend a "s:" to your key.
    ex: kukri -c accesspoint s:password
    Missing a feature? Contact me.
    HELP
    INTERFACE = :wlan0 # Edit for default extension
    DHCPCLIENT = :dhclient # Edit for default dhcp client
    class WifiTools
    def initialize interface = INTERFACE
    @interface = interface
    end
    def scan
    networks = `iwlist #{@interface} scan`.split(/Cell \d*/)
    networks.shift
    networks.each do |results|
    puts results.match(/SSID:\".*"/).to_s.gsub('"','')
    print "\t", results.match(/Channel:\d+/).to_s.concat("\n")
    print "\t", results.match(/Quality=\d+\/\d+/).to_s.sub("Quality=",'Strenth:').to_s.concat("\n")
    print "\t", results.match(/Encryption .*\s/).to_s.sub(' ',':')
    end
    end
    def connect essid, key = nil
    if `sudo ifconfig wlan0 up` != ''
    abort("Please run the script using sudo or as root")
    end
    unless key
    puts "Connecting to #{essid}"
    if `sudo iwconfig #{@interface} essid #{essid}` == ''
    puts "Connected to #{essid}"
    else
    abort("Could not connect")
    end
    else
    puts "Connecting to #{essid} with WEP encryption"
    if `sudo iwconfig #{@interface} essid #{essid} key #{key}` == ''
    puts "Connected to #{essid}"
    else
    abort("Could not connect")
    end
    end
    `sudo #{DHCPCLIENT} -q -n #{@interface}`
    puts "#{DHCPCLIENT.to_s.capitalize} started."
    end
    def disconnect
    "Disconnecting #{@interface}"
    if `sudo iwconfig #{@interface} essid off` != ''
    "Disconnect failed! Try running as root"
    end
    end
    def information
    "Current Connection"
    info = `iwconfig #{@interface}`
    puts info.match(/SSID:\".*"/)
    puts info.match(/Quality=\d+\/\d+/).to_s.sub("Quality=",'Strenth:')
    end
    end
    #wifi = Config.new(ARGV.first) if ARGV.first =~ /\w\d/ else
    case ARGV.first()
    when /\w\w/
    wifi = WifiTools.new(ARGV.shift)
    else
    wifi = WifiTools.new()
    end
    case ARGV.first()
    when "--scan", "-s"
    wifi.scan
    when "--connect", "-c"
    wifi.connect ARGV[1], ARGV[2]
    when "--disconect", "-d"
    wifi.disconnect
    when "--information", "-i"
    wifi.information
    when "--help", "-h"
    print $help
    else
    print $help
    end

    Because this isn't a project and netcfg didn't work for me. So I just made something that will work without a lot of hassle.

  • Sending BitmapData to Ruby On Rails

    Hi
    I have a project that has a SAVE button that on click needs to save a PNG file of an area of the stage (or a MC if that is easier) to a server and put and entry for said file into a database. The database end of things is going to be handled by the web developer so not a concern for me.
    I found an example on the web that uses PHP to write the PNG file to a remote drive, and the ActionScript just needed to call a PHP page with POST variables to execute the save. I cannot however find any examples of how to do this with Ruby On Rails. Would the methodology be the same; call a URL to a Ruby script and send the variables via POST? In which case the ActionScript side of things would essentially be the same as for the PHP method? Or does using RoR require some other means of executing this kind of function?
    Many thanks for any advice. I'm out of my league on this one
    cheers
    adam

    I would say that YES the method should be the same -- at least inasmuch as you are POSTING enough data to make the image to your server.  Ruby should be able to find the bitmap data in POST.

  • Update Ruby with Mountain Lion

    I have successfully updated Ruby in the past with Snow Leopard 10.6.3 and 10.6.8; however, I'm having an issue doing so with Mountain Lion 10.8.2. I have searched all over, trying to use Homebrew as well as RVM. RVM is shown to be not instaled. I used Jewelrybox, and it installed, showing .bash_profile. But RVM command is showing as an invalid command. I also upgraded Ruby that way as well as with Homebrew. So I have updated Ruby twice with 2 different methods, but running Ruby -v show older 1.8.7. How do I make the path to show the new updated Ruby. I have tried so many ways. Last resort... ask communty. Thanks!

    I chose not to try and update the Ruby that is installed by OS X, but I did successfully install the Ruby Version Manager (rvm) into my $HOME/.rvm.
    If you are the sole account on your machine, or the only one using Ruby, then you do not want to be root or use sudo when installing rvm, as these permissions imply multi-user usage and (if I remember correctly) will place it in /usr/local/ruby-rvm.
    Start over. Remove any reference to rvm in .bashrc, .bash_login, and .zshrc. Any reference to rvm in these files will bork a subsequent install.
    Remove $HOME/.rvm if it already exists.
    Again, for reference, here is the rvm installation and setup steps. The site has other useful info on gemsets and Rails.
    I chose to install ruby-1.9.3-head as default.
    In your Ruby scripts, the first line should look like this:
    #! /usr/bin/env ruby
    This picks up the rvm ruby version.
    The first part of my PATH entry in my .bashrc file looks like this:
    export PATH=.:~/bin:~/.rvm/bin:$PATH
    You should have a working Ruby in no time.
    PS: You will need 1.9.3 minimum to get the Ruby code compiled under OS X. Pay attention to the Ruby requirements during install.

  • Insane XML Import, Huge Project, Duplicate file names work around...

    I planned on kicking off my journey attempting to edit a massive multi year documentary on FCPX with a nice introduction of the blog I'm going to keep about the experience, but I've run into a bit of a roadblock, or maybe major speed bump at least before even getting to that point. I wanted to share what is working as a work around for me and you guys can tell me how I'm doing it wrong.
    Ok, I will try to explain this as succinctly as possible. I'll write in somewhat stream of consciousness just to try and get through it quicker... Basically, after discovering the work around below, I am now utterly confused on how FCPX handles the relationship between its own database of where media is stored, and the actual media itself. I have plenty experience on FCPX now, probably done 30-40 pro commercial jobs on it over the last year since XML became doable as I'm also a Resolve Colorist and all the FCPX projects where hardcore coloring product spots. For commercial work, I never needed to worry about splitting up footage up over multiple Events. Everything, all in one, FCPX handled it no problem. (well the occasional beach ball, but that seems to be a thing with FCPX in general)
    This will be my 10th feature documentary as an Editor. Every one before it was either on Avid's many flavors over the last 12 years or FCP Studio. When this new film came along, I made the decision a few months ago to use FCPX for a few reasons, but mostly because I'm insane and I like to try to mix it up for myself in a career that can get stale quick if you aren't willing to be that way. The film was shot over 2+ years, every shoot was multi cam 5D (yes i know, looks great, but please kill me), I haven't done the math on length, but there is over 10,000 clips of video (this is actually medium in size compared to what I've dealt with before). Its 5D, so theres external audio for everything. FCPX's syncing is great, but I've learned that theres an unsaid window of heads and tales clips must fall within to sync properly with the nearby clips, if they are too far apart FCPX gives up. One shoot day could have 3 cams, 50 clips each, and 2 audio files to sync to, FCPX simply cannot handle this, so off to Plural eyes they went, no problems.
    Ok, all this is relevant eventually I swear! Again, in the past, all in one event, no problem. I tried for fun to bring all media into one Event on this film. It worked, but there is a 10+ second spinning beach ball for every single move you make, so thats no good. Ok, I'll separate the Events out to, lets say, each shoot month. Well that's dumb, in verite documentary, any shot could be the first, any shot could be the last, you need a command over all searchable footage at all times. Shift selecting all events to search *****, and it actually takes longer for FCP to reload each event each time than it does to just have the one massive one. So no go there. Next hair brained idea... What if make a new Event that is just Compound Clips of all the other Event's contents and do more with Markers and Favorites in logging that I was planning to parse it all out. That way I'm working with and FCPX is dealing with 50-60 clips instead of 10,000+ Quick test, Cmd-A, Opt-G, boom, boom, boom, move all to dedicated to Event, hide huge Event, BEHOLD, that works! FCPX chokes a little bit on the insane length of some of the clips, but searching, and general performance is back on par!
    So your saying to yourself "Ok *********, sounds like you figured it out, what's the problem." Well to you I say, "Not so fast!" Remember, that was just a quick test using the media I had imported into the massive 10,000+ clip Event. To do this project proper, I am having to import Multicam sync'd XMLs from Plural Eyes. And this is where it all starts to fall apart. A little foreshadowing for your eager eyes. 10,000+ files all shot with multiple 5D's over the course of years. What does that mean? many, many duplicate file names!
    FCPX as well all know irritatingly imports XML's as new Events, not into existing ones. This obviously takes a lot of burden off media management because with a new Event comes a new database referencing its own version of the raw media. All well and good, and I'm betting its starting to click for some if you advanced users where I'm finally going with this. So I have 50 or so XMLs to bring in, all done no problem. Now I want to replicate that singular Event like I did with the Compound Clip test and have it all in one place to be my master as extensive logging begins for easy searching once editing begins. Highlight the Events, click Merge Events. NOPE. I get a new "Kill Yourself Now" error (a term I coined for Out of Memory and General Error messages in FCP Legacy meaning there ain't much you can do about it): "Two or more files have the same name. Change the names and try again, because I don't know what the **** to do with them." Ok I made up that last part but that's basically what it's saying. Just take the variable out of the equation, this happens with every which way you could try to get the clips together. Merge Events, dragging events on top of each other, dragging just the Multicam clip alone, nothing gets passed that message. What's worse is that while Batch Renaming seems like a solution, the renames do not populate inside the created clips and there is no way to Batch Rename those. Renaming everything at the finder level isn't so great because then I'd have to resync and theres an offline/online thing going here where the film has to be reconformed eventually.
    Basically, I've found that FCPX handles media management in completely different ways depending on whether you are importing into one Event yourself or doing essentially what is a new import with FCPX moving or merging Events. If you bring in all the media to one Event, on a macro level FCPX goes through file by file making aliases referencing the master file. If it hits a duplicate, it makes a parenthesis counter, and keeps going. And with the genius of FCPX metadata, that file name doesn't even matter, you can change it at the Finder level and FCPX will keep the link intact. BUT for some reason if you try to do this outside the realm of a single Event and combine files after the fact a different process takes over in creating this database system and can't handle the duplicates. I can't totally figure the reason other than it probably is scared to change the originally referenced alias to something else (which it shouldn't be scared of since Merge Events deletes the original anyway).
    This is where it gets INSANE and where I lose all understanding of what is going on, and believe me it was a delicate understanding to begin with. It comes in to play with the work around I figured out. I make the master Event with the 10,000+ clips. Then I import all the XMLs as dedicated Events. Now, I then drag the Multicam clips into the master Event, it WORKS! just takes it, no "Kill Yourself Now" error. Stranger still, now with the switched referenced Event, it even takes into account which aliased duplicate file name it's referencing in the Original Media folder. Somehow, it's taking into account the original file path and saying "Ok, I see 5 instances of MVI_5834.mov. Based on the original file path or maybe creation date or god knows what, it must be MVI_5834 (fcp3).mov." It connects perfectly. I can even remove the old XML imported Event with no problem. Crazier yet, I can now move those again to the dedicated Event I wanted originally that only contains those Multicam or Compound Clips.
    So instead of going straight from A to C, going from A to B to C works even though that actually seems way more complicated. Why can't FCPX handle Merge Events and dragging clips the same way it handles media imported into a single Event. And weirder still, why can't FCPX handle the (fcp1,2,3...) appending in the same scenario. But if the appended links are already there, No Problem. And for the love of god, it'd be nice to important XML's into existing Events and make the correct referencing happen right from the get go, which is really the source of all the above headache. I'd have no problem helping FCPX with a little manual pointing in the right direction just like any other NLE needs.
    Ok, having said all of that crap above, my question is, have I missed something completely simple I should have done instead? Now that I have everything in place how I originally envisioned, I think I will still play around a little bit more to make sure FCPX is really going to be able to handle this project. I'm at a stage right now where going another direction is still an option, although the dare devil in me wants to make this work. Media management aside, once you start editing on a FCPX timeline, its hard to go back to anything else. Apple is going to have to figure out some way not to access to everything at all times to work fluidly or big projects like this are never going to be practical in FCPX.
    Sorry for the long confusing post....

    I'm having the exact same problem, but I know nothing of ruby scripts. I've exhausted my resources with tech support, and after literally hours of work with them it seems I now am faced with either re-rating each individual song, or pointing iTunes to each song that it can't locate. Is yours a solution that could help me? How can I find out more about Ruby Scripts? Thanks for your help, hellolylo (or anyone else who might also be able to help...)
    Kenn

  • SMB client URL works in 10.4.10, breaks in 10.5 -- password not accepted

    Hi,
    The SMB client URL (Finder Command-K) that was working under 10.4.10 breaks under 10.5:
    smb://DOMAIN-name;userid@Fully-qualified-DN-for-WinServer/PrivateSharename$
    The symptom is that the Mac does connect to the WinServer, as I do get the userid/password prompt, with the userid already prefilled as DOMAIN-name\userid. But when I add my Windows password and submit, I get a delay and then a message my userid or password is invalid.
    I know my userid and password are valid as they work from my PC, as well as from my Mac as far as establishing a Mac to PC screensharing session using MS Remote Desktop Connection.
    I know that it's not a network, DNS, or WINS name resolution problem as I do get as far as the initial connection to the PC -- i.e. the userid/password prompt. As well I've tried using the Windows Server's IP address directly in the URL.
    I've read the threads here and tried these variants of the URL:
    smb://DOMAIN-name;userid@IP-of-WinServer/PrivateSharename$
    smb://DOMAIN-name;userid:win-password@IP-of-WinServer/PrivateSharename$
    I've tried the Ruby script to escape any funny characters in my win-password; but there are none anyways, and the output from the Ruby script mentioned in another thread are the same as my inputted password.
    I've also gone into /etc/smb.conf and added the line suggested in another thread:
    client NTLMv2 auth = Yes
    ...and rebooted. But that line is for Windows clients trying to connect to a samba server running on the Mac. I'm doing the opposite: trying to run a Samba client connection to a PC server.
    Bottom line:
    OS X 10.4.10 : no problem connecting to Windows server
    OS X 10.5 : cannot
    suggestions welcome,
    ...b

    OK, so this SMB client URL (in the Finder, press Command-K) that was working under 10.4.10 breaks under 10.5:
    smb://domain;[email protected]/share
    so I added my domain name and WINS servers into the WINS tab of the Networking Preference Pane, and I was then able to browse our windows network in the Finder, find the above Win2003 PC server name, and connect! Yay!
    So I went back and tried variations on the SMB URL above. Until finally this variation worked:
    smb://domain;userid@server/share
    Hmm. So server.domain.company.com which does resolve to the PC server's IP, no longer works under OS X 10.5 -- even though the same SMB URL worked in OS X 10.4.
    Worse, while smb://domain;userid@server/share now works on the company LAN, smb://domain;userid@server/share fails over the company (cisco) VPN.
    I speculate it's because OS X 10.5 is using the PC servers NetBIOS name above and therefore relying on various PC WINS server ports, whose packets can flow unimpeded over my LAN. But when I'm VPN'ing, the company LAN I land on blocks these packets and ports.
    So after much tinkering, I returned to the Terminal.app and started reading the man pages about Samba, the open source Windows networking software used by OS X:
    man -k smb <-- to look up all the terminal commands for samba
    one of the entries this returned was:
    nsmb.conf(5) - configuration file for SMB requests
    Hmm, that sounds promising.
    man nsmb.conf
    returned a sample configuration file. I edited the sample file to include our windows "domain" name, and to map our "server" name to it's fully-qualified DNS name: "server.domain.company.com", and put this updated file, as per the man pages, in ~/Library/Preferences/nsmb.conf, and volia:
    smb://domain;userid@server/share
    now works for me to connect from OS X 10.5 to the "server" over our LAN and over our VPN!
    This was a lot of work and not a general solution. OS X 10.4 was definitely better, but this is the only PC server I need to connect to, so I'm very happy that I don't have to uninstall Leopard and re-install Tiger.
    ...b

Maybe you are looking for

  • Setup.exe does not execute - Oracle 10g on windows xp!?

    Hello, I have a problem while installing Oracle 10g Release 2 on my XP-prefessional machine (including service pack 2). By doubleclicking the autorun-file the openingdialog pops up, but after I chossed Installation nothing happens - the same by start

  • Video disappears when exporting to Interactive pdf

    Hi, I have just started using InDesign yesterday and am trying to put together an interactive pdf. It is essentially a pdf catalogue with several clients on it. I have carried out all the hyperlinking, but now I want to embed a video into the pdf. I

  • Link PR (ME52N) to table SOOD

    Hello, I used the serivces for objects features in ME52N. I was able to attach a document via this feature. When I checked in table SOOD, it was there. However, I could not link the PR Number to table SOOD. What should be the link for this? Or should

  • Need help in installing jmf

    Hi friends, i installed jmf-2_1_1e-windows-i586 to c:\programfiles .i need it just to capture image from webcam using java code.I installed it and read the readme about seting classpath and path.i have set it as follows i dont know whether to change

  • Found invalid html file ??

    For WebHelp text popup boxes, early versions of RH stored the text in the topic. Since RH5X, maybe earlier, RH generates small html files with file names like this: Topicfilename_text0.htm Topicfilename_text1.htm Topicfilename_text2.htm Secondtopicfi