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.

Similar Messages

  • 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.

  • 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

  • Report script. no proper response .....help required

    hi
    in my report script have i USD and INR
    when i run the script i get
    USD
    INR
    USD
    INR
    INR
    but isit possible to have USD INR separately in another column?
    cheers

    i tried like this
    <row(year,account period.... but i dint mention no currency)
    <coloum (SGD,USD)
    but i dint get the format which i was loooking at infact i cant even c the currency coloumn even !!

  • Have latest greasemonkey everytime i try to load scripts get this response: Script could not be installed TypeError: this._initScriptDir is not a function

    Mac OS X, firefox 3.5.7, greasemonkey 0.9.8 these are ex of script been trying to load. http://userscripts.org/scripts/show/101052

    same with Firefox (IceWeasel v3.5.16) - Debian Squeeze 64bit - grease monkey 0.9.8

  • 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)

  • 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

  • IOS Mobile Device Management - The SCEP server returned an invalid response

    I am in the process of writing an open source iOS mobile device management module in Java. For this I am referring the Apple provided Ruby code at [1]. I have set this up and it works fine for me. Now I need to convert this code to Java. So far I have accomplished to do that up to PKIOperation. In the PKI operation I get "The SCEP server returned an invalid response" which I believe is due to wrong response I sent to device upon PKIOperation.
    However when I do search on the internet I get this is something to do with the "maxHttpHeaderSize" as I am using the server as Apache Tomcat. Although I increase that since still it does not get resolved.
    Here is the code I need to convert - taken from Apple provided Ruby script
    if query['operation'] == "PKIOperation"
        p7sign = OpenSSL::PKCS7::PKCS7.new(req.body)
        store = OpenSSL::X509::Store.new
        p7sign.verify(nil, store, nil, OpenSSL::PKCS7::NOVERIFY)
        signers = p7sign.signers
        p7enc = OpenSSL::PKCS7::PKCS7.new(p7sign.data)
        csr = p7enc.decrypt(@@ra_key, @@ra_cert)
        cert = issueCert(csr, 1)
        degenerate_pkcs7 = OpenSSL::PKCS7::PKCS7.new()
        degenerate_pkcs7.type="signed"
        degenerate_pkcs7.certificates=[cert]
        enc_cert = OpenSSL::PKCS7.encrypt(p7sign.certificates, degenerate_pkcs7.to_der,
            OpenSSL::Cipher::Cipher::new("des-ede3-cbc"), OpenSSL::PKCS7::BINARY)
        reply = OpenSSL::PKCS7.sign(@@ra_cert, @@ra_key, enc_cert.to_der, [], OpenSSL::PKCS7::BINARY)
        res['Content-Type'] = "application/x-pki-message"
        res.body = reply.to_der
    end
    So this is how I written this in Java using Bouncycastle library.
    X509Certificate generatedCertificate = generateCertificateFromCSR(
                    privateKeyCA, certRequest, certCA.getIssuerX500Principal()
                            .getName());
            CMSTypedData msg = new CMSProcessableByteArray(
                    generatedCertificate.getEncoded());
            CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();
            edGen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(
                    receivedCert).setProvider(AppConfigurations.PROVIDER));
            CMSEnvelopedData envelopedData = edGen
                    .generate(
                            msg,
                            new JceCMSContentEncryptorBuilder(
                                    CMSAlgorithm.DES_EDE3_CBC).setProvider(
                                    AppConfigurations.PROVIDER).build());
            CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
            ContentSigner sha1Signer = new JcaContentSignerBuilder(
                    AppConfigurations.SIGNATUREALGO).setProvider(
                    AppConfigurations.PROVIDER).build(privateKeyRA);
            List<X509Certificate> certList = new ArrayList<X509Certificate>();
            CMSTypedData cmsByteArray = new CMSProcessableByteArray(
                    envelopedData.getEncoded());
            certList.add(certRA);
            Store certs = new JcaCertStore(certList);
            gen.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(
                    new JcaDigestCalculatorProviderBuilder().setProvider(
                            AppConfigurations.PROVIDER).build()).build(
                    sha1Signer, certRA));
            gen.addCertificates(certs);
            CMSSignedData sigData = gen.generate(cmsByteArray, true);
            return sigData.getEncoded();
    The returned result here will be output in to the servlet output stream with the content type "application/x-pki-message".
    It seems I get the CSR properly and I generate the X509Certificate using following code.
    public static X509Certificate generateCertificateFromCSR(
            PrivateKey privateKey, PKCS10CertificationRequest request,
            String issueSubject) throws Exception {
        Calendar targetDate1 = Calendar.getInstance();
        targetDate1.setTime(new Date());
        targetDate1.add(Calendar.DAY_OF_MONTH, -1);
        Calendar targetDate2 = Calendar.getInstance();
        targetDate2.setTime(new Date());
        targetDate2.add(Calendar.YEAR, 2);
        // yesterday
        Date validityBeginDate = targetDate1.getTime();
        // in 2 years
        Date validityEndDate = targetDate2.getTime();
        X509v3CertificateBuilder certGen = new X509v3CertificateBuilder(
                new X500Name(issueSubject), BigInteger.valueOf(System
                        .currentTimeMillis()), validityBeginDate,
                validityEndDate, request.getSubject(),
                request.getSubjectPublicKeyInfo());
        certGen.addExtension(X509Extension.keyUsage, true, new KeyUsage(
                KeyUsage.digitalSignature | KeyUsage.keyEncipherment));
        ContentSigner sigGen = new JcaContentSignerBuilder(
                AppConfigurations.SHA256_RSA).setProvider(
                AppConfigurations.PROVIDER).build(privateKey);
        X509Certificate issuedCert = new JcaX509CertificateConverter()
                .setProvider(AppConfigurations.PROVIDER).getCertificate(
                        certGen.build(sigGen));
        return issuedCert;
    The generated certificate commonn name is,
    Common Name: mdm(88094024-2372-4c9f-9c87-fa814011c525)
    Issuer: mycompany Root CA (93a7d1a0-130b-42b8-bbd6-728f7c1837cf), None
    [1] - https://developer.apple.com/library/ios/documentation/NetworkingInternet/Concept ual/iPhoneOTAConfiguration/Introduction/Introduction.html

    I am in the process of writing an open source iOS mobile device management module in Java. For this I am referring the Apple provided Ruby code at [1]. I have set this up and it works fine for me. Now I need to convert this code to Java. So far I have accomplished to do that up to PKIOperation. In the PKI operation I get "The SCEP server returned an invalid response" which I believe is due to wrong response I sent to device upon PKIOperation.
    However when I do search on the internet I get this is something to do with the "maxHttpHeaderSize" as I am using the server as Apache Tomcat. Although I increase that since still it does not get resolved.
    Here is the code I need to convert - taken from Apple provided Ruby script
    if query['operation'] == "PKIOperation"
        p7sign = OpenSSL::PKCS7::PKCS7.new(req.body)
        store = OpenSSL::X509::Store.new
        p7sign.verify(nil, store, nil, OpenSSL::PKCS7::NOVERIFY)
        signers = p7sign.signers
        p7enc = OpenSSL::PKCS7::PKCS7.new(p7sign.data)
        csr = p7enc.decrypt(@@ra_key, @@ra_cert)
        cert = issueCert(csr, 1)
        degenerate_pkcs7 = OpenSSL::PKCS7::PKCS7.new()
        degenerate_pkcs7.type="signed"
        degenerate_pkcs7.certificates=[cert]
        enc_cert = OpenSSL::PKCS7.encrypt(p7sign.certificates, degenerate_pkcs7.to_der,
            OpenSSL::Cipher::Cipher::new("des-ede3-cbc"), OpenSSL::PKCS7::BINARY)
        reply = OpenSSL::PKCS7.sign(@@ra_cert, @@ra_key, enc_cert.to_der, [], OpenSSL::PKCS7::BINARY)
        res['Content-Type'] = "application/x-pki-message"
        res.body = reply.to_der
    end
    So this is how I written this in Java using Bouncycastle library.
    X509Certificate generatedCertificate = generateCertificateFromCSR(
                    privateKeyCA, certRequest, certCA.getIssuerX500Principal()
                            .getName());
            CMSTypedData msg = new CMSProcessableByteArray(
                    generatedCertificate.getEncoded());
            CMSEnvelopedDataGenerator edGen = new CMSEnvelopedDataGenerator();
            edGen.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(
                    receivedCert).setProvider(AppConfigurations.PROVIDER));
            CMSEnvelopedData envelopedData = edGen
                    .generate(
                            msg,
                            new JceCMSContentEncryptorBuilder(
                                    CMSAlgorithm.DES_EDE3_CBC).setProvider(
                                    AppConfigurations.PROVIDER).build());
            CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
            ContentSigner sha1Signer = new JcaContentSignerBuilder(
                    AppConfigurations.SIGNATUREALGO).setProvider(
                    AppConfigurations.PROVIDER).build(privateKeyRA);
            List<X509Certificate> certList = new ArrayList<X509Certificate>();
            CMSTypedData cmsByteArray = new CMSProcessableByteArray(
                    envelopedData.getEncoded());
            certList.add(certRA);
            Store certs = new JcaCertStore(certList);
            gen.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(
                    new JcaDigestCalculatorProviderBuilder().setProvider(
                            AppConfigurations.PROVIDER).build()).build(
                    sha1Signer, certRA));
            gen.addCertificates(certs);
            CMSSignedData sigData = gen.generate(cmsByteArray, true);
            return sigData.getEncoded();
    The returned result here will be output in to the servlet output stream with the content type "application/x-pki-message".
    It seems I get the CSR properly and I generate the X509Certificate using following code.
    public static X509Certificate generateCertificateFromCSR(
            PrivateKey privateKey, PKCS10CertificationRequest request,
            String issueSubject) throws Exception {
        Calendar targetDate1 = Calendar.getInstance();
        targetDate1.setTime(new Date());
        targetDate1.add(Calendar.DAY_OF_MONTH, -1);
        Calendar targetDate2 = Calendar.getInstance();
        targetDate2.setTime(new Date());
        targetDate2.add(Calendar.YEAR, 2);
        // yesterday
        Date validityBeginDate = targetDate1.getTime();
        // in 2 years
        Date validityEndDate = targetDate2.getTime();
        X509v3CertificateBuilder certGen = new X509v3CertificateBuilder(
                new X500Name(issueSubject), BigInteger.valueOf(System
                        .currentTimeMillis()), validityBeginDate,
                validityEndDate, request.getSubject(),
                request.getSubjectPublicKeyInfo());
        certGen.addExtension(X509Extension.keyUsage, true, new KeyUsage(
                KeyUsage.digitalSignature | KeyUsage.keyEncipherment));
        ContentSigner sigGen = new JcaContentSignerBuilder(
                AppConfigurations.SHA256_RSA).setProvider(
                AppConfigurations.PROVIDER).build(privateKey);
        X509Certificate issuedCert = new JcaX509CertificateConverter()
                .setProvider(AppConfigurations.PROVIDER).getCertificate(
                        certGen.build(sigGen));
        return issuedCert;
    The generated certificate commonn name is,
    Common Name: mdm(88094024-2372-4c9f-9c87-fa814011c525)
    Issuer: mycompany Root CA (93a7d1a0-130b-42b8-bbd6-728f7c1837cf), None
    [1] - https://developer.apple.com/library/ios/documentation/NetworkingInternet/Concept ual/iPhoneOTAConfiguration/Introduction/Introduction.html

  • How can I use a script to search for a list of filenames and copy them to another directory

    Hi all,
    I'm quite new to using scripts etc and wondered if anyone could help? I've only ever modified preset folder scripts so making one from scratch is a bit new to me, but it would also be great if anyone else has done this before if they could pass on there script and ill modify to suit my needs.
    I will be recieving a tab delimited file containing a list of 150 - 200 clips every day and I need to pull those files onto a hard drive.
    All of the files are housed in one folder on the internal media drive and I would like to be able to have applescript / automator / whatever  either look through the tab file and then move the files in the tab file from the internal media drive to the external transport drive or I copy and paste the filenames into the script and run it and the script moves the files from the internal media drive to the external transport drive.
    Hope someone can help,
    Many Thanks

    There are no other files in the source video root folder nor are there any folders within the subfolders.
    I have tested the script and the response I am getting is this....
    Could this be something to do with the {} on the set filestoMove command?
    In the replies box I get the following....
    tell current application
      read alias "Macintosh HD:Users:Ben:Desktop:Untitled.txt"
      --> "000004_1__4michaeljmcevoy_4iLlBuDjjG0"
    end tell
    tell application "System Events"
      count folder "Macintosh HD:Users:Ben:Desktop:source"
      --> 10
      count item 1 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> 1
      get name of item 1 of item 1 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> ".DS_Store"
      count item 2 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> 1
      get name of item 1 of item 2 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> "000004"
      count item 3 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> 1
      get name of item 1 of item 3 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> "000005"
      count item 4 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> 1
      get name of item 1 of item 4 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> "000006"
      count item 5 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> 1
      get name of item 1 of item 5 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> "000007"
      count item 6 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> 1
      get name of item 1 of item 6 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> "000008"
      count item 7 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> 1
      get name of item 1 of item 7 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> "000009"
      count item 8 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> 1
      get name of item 1 of item 8 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> "000010"
      count item 9 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> 1
      get name of item 1 of item 9 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> "000011"
      count item 10 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> 1
      get name of item 1 of item 10 of folder "Macintosh HD:Users:Ben:Desktop:source"
      --> "000012"
    end tell
    tell application "Finder"
      -- 'core'\'clon'{ 'insh':'alis'($000000000152000200010C4D6163696E746F7368204844000000000000000000 000000000000CA40F7FC482B00000006AB3D06736F75726365000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 00000007FD33CAFABF2E0000000000000000FFFFFFFF000009200000000000000000000000000000 00074465736B746F7000001000080000CA40E9EC0000001100080000CAFABF2E00000001000C0006 AB3D0006AA9B0000BEEC000200284D6163696E746F73682048443A55736572733A0042656E3A0044 657…
      --> {}
    end tell
    Result:

  • SVG with PNG fallback, Responsive, EDGE Reflow & Animate integration

    I mentioned this on the Muse Facebook, and they said I should post it here... I think Muse is an awesome program. But I really, really would love to see these features. Any of them good enough to make it to the sketching table?
    1. SVG with PNG fallback support (for Retina displays)
    The problem with Hi-Res displays on Tablets, phones and laptops is that the web is becoming awfully ugly. You need to zoom to fit webpages, and when they fit, the JPG's and PNG's become blurry. Since displays are increasing resolution year after year and pixel density is becoming a real issue, on phones (like the HTC One) or laptops (Macbook Retina or Chromebook Pixel).
    Wouldn't it be great if we could use vector SVG for new devices for sharp a crisply logo's on every screen. And with that instantly use an automatic PNG-fallback option for older browsers. This would signifantly upgrade any website made with Adobe Muse and the Web in general if you ask me! I've done some research and I found this website very useful considering this issue: http://toddmotto.com/mastering-svg-use-for-a-retina-web-fallbacks-with-png-script/
    2. Responsiveness (Adobe EDGE reflow integration)
    Adobe Reflow is amazingly promising. What if (instead of making different websites for every device) you can export a website to Adobe Reflow to make the design instantly responsive.
    3. Beter Adobe EDGE Animate integration
    EDGE Animate is a great program, especially with the codes and actions which you cna integrate. The only problem is sometimes I want an animation to start playing when I'm at that part of the page, not after when it's done loading. Overall the integration is so-so, and it's doable to add an animation to Muse, but these tweaks could upgrade it from great, so turbo-awesome!
    Which brings me to my next point:
    4. Dynamic Content Loading (Load on view)
    Isn't Muse a great tool for making one-pages?! I love it for that, and I do love one-pages. The problem is that it can take a while to load when it's becoming more complex. Is there a possibility to add a feature when thing are loaded when you scroll? Which is fairly often used on blogs and stuff.
    5. Horizontal Parralax Scrolling
    Since the latest update I've been pretty hooked on the functions of parralax scrolling and what it could do in a usefull way. The problem is that it doensn't work for horizontal scrolling. The objects can move horizontal (when scrolling vertical). But there's no option to add an effect when scrolling in a horizontal direction.
    What do you think? Any of these interesting enough to develop?

    I would love all of the features in this post. But you must post it in the Idea section of the forum so people can vote for your ideas.

  • [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)

  • 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.

  • Script to delete users created in database after specific days

    Hi,
    I am working as a QA. In my team, we need to create oracle users frequently for testing purpose but no one deletes user from oracle after finishing testing thus creating lots of user in oracle and also wasting lots of space. so need help to create a script which will delete user defined table after specific days which we can set in script ?
    Early response will be appreciable.
    Thanks in advance

    Its a oracle users which are created by team members for testing purposeprogramatically how will you differentiate between schemas/usernames created by Oracle & those created locally?
    SQL> select username, created from dba_users order by 2;
    USERNAME                 CREATED
    SYSTEM                      15-AUG-09
    SYS                      15-AUG-09
    OUTLN                      15-AUG-09
    DIP                      15-AUG-09
    ORACLE_OCM                 15-AUG-09
    DBSNMP                      15-AUG-09
    APPQOSSYS                 15-AUG-09
    WMSYS                      15-AUG-09
    EXFSYS                      15-AUG-09
    CTXSYS                      15-AUG-09
    ANONYMOUS                 15-AUG-09
    XDB                      15-AUG-09
    XS$NULL                  15-AUG-09
    MDSYS                      15-AUG-09
    ORDSYS                      15-AUG-09
    SI_INFORMTN_SCHEMA            15-AUG-09
    ORDDATA                  15-AUG-09
    ORDPLUGINS                 15-AUG-09
    OLAPSYS                  15-AUG-09
    MDDATA                      15-AUG-09
    SPATIAL_WFS_ADMIN_USR            15-AUG-09
    SPATIAL_CSW_ADMIN_USR            15-AUG-09
    SYSMAN                      15-AUG-09
    MGMT_VIEW                 15-AUG-09
    APEX_030200                 15-AUG-09
    APEX_PUBLIC_USER            15-AUG-09
    FLOWS_FILES                 15-AUG-09
    OWBSYS                      15-AUG-09
    OWBSYS_AUDIT                 15-AUG-09
    SCOTT                      15-AUG-09
    IX                      07-MAY-10
    BI                      07-MAY-10
    SH                      07-MAY-10
    HR                      07-MAY-10
    PM                      07-MAY-10
    OE                      07-MAY-10
    DBADMIN                  07-MAY-10
    BONGO                      22-MAY-10
    USER1                      30-AUG-10
    SAM                      29-SEP-10
    40 rows selected.which "old" schemas need to be discarded.
    post SELECT that properly produces usernames to be removed.

Maybe you are looking for

  • How do I add different sites to search engines

    How do I add other search engines or sites to my drop down list? When I visit a site nothing comes up in the drop down menu to 'add it' like the instructions say and you can't manage it to add. I want to add Dogpile and at the Dogpile site it says 'a

  • ICloud not working on 3gs, please help!

    Hi, i've just updated my iPhone 3gs to iOS5. All seems to be working fine, apart from iCloud. The Wi-Fi sync and everything else is great. However, on the settings option, iCloud, Photo Stream, and Twitter are greyed out. The option is still availabl

  • Alerts to Approver on PO creation & to vendor on PO approval

    Hi, Requirement is to send the alerts to the approver on PO creation and on approval - the alert should be sent to the vendor. Can anyone please help me out as to how can we handle both these requirements ? Thanks in Advance to All !!!! Regards, Laxm

  • Hot Audio

    Any quick advice to rescure some slightly distorted audio? The input level was a wee too high. Details: Sound is speech only (save for a droning compressor nearby that was also unavoidably picked up). The mic was a Sennheiser ew 100 G2 wireless laval

  • I have a mac with os x 10.6.8, should I upgrade it to os x 10.9.is there any problem which can occur after upgrading my os.

    I have a mac with os x 10.6.8, should I upgrade it to os x 10.9.is there any problem which can occur after upgrading my os.