JCOP Shell: parsing responses in a script

I've been reading through the (sparse) documentation for the JCOP shell, but can't find how to parse a response APDU coming back from the card in a script.
Does anyone know how to do this?
thanks!

OK, after some more thorough forum searching, I found the following thread:
http://forum.java.sun.com/thread.jspa?forumID=23&threadID=654224
Summary:
- /send response goes in a special (undocumented!) variable called ${response}
- /send takes a second parameter which is the expected response
Hope that saves someone else some time. I think it is rediculous that these basic features are not properly documented in the JCOP tools.

Similar Messages

  • Applet runs via JCOP shell, but not from CardReader

    Hi,
    I'm completely new to JavaCard, JCOP and Eclipse, so maybe this is a stupid question. But I just need the answer.
    I created a simple javacard applet just to get known to all this new stuff. Now I am able to debug my applet in the Eclipse environment debugger and run it in my test hardware. When I run it (on the OMNIKEY ICCD test hardware), I'm able to send commands to the card and I get back the expected responses.
    In the JCOP Shell, I only need to select the applet (/select |<application name>) and after that send a command (send 8002000009, in my case read 9 bytes starting at location 0x00). In the Shell, I correctly get back the expected data.
    When I disconnect the USB cable for communication between Shell and development hardware and put this hardware into a CardReader, the ATR is detected, just as seen in the Shell. But then, whatever commands I send, I get responses I can't explain. Below some example.
    To be clear, I did nothing but running the applet in the IDE and after that disconnected the cable. Is there some special step/command needed between a run from the Eclipse environment and run "in the real world"??
    Can anyone give me a clue for this??
    First case, Send five zero bytes after ATR
    ATR
    Received: ['0x3b', '0xfa', '0x13', '0x0', '0x0', '0x81', '0x31', '0xfe', '0x45', '0x4a', '0x43', '0x4f', '0x50', '0x34', '0x31', '0x56', '0x32', '0x32', '0x31', '0x96'] (length = 20)
    * Found header
    * TC1 = 0x81
    J C O P 4 1 V 2 2 1
    Send <0000000000>
    Received: ['0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x0', '0x2', '0x6e', '0x0', '0x6c'] (length = 11)
    Send <00a40000023f00>
    Received: ['0x0', '0xa4', '0x0', '0x0', '0x2', '0x3f', '0x0', '0x0', '0x92', '0x0', '0x92'] (length = 11)
    Send <0a404000a546573744170706c65740>
    Received: ['0x0', '0xa4', '0x4', '0x0', '0xa', '0x54', '0x65', '0x73', '0x74', '0x41', '0x70', '0x70', '0x6c', '0x65', '0x74', '0x0', '0x0', '0x92', '0x0', '0x92'] (length = 20)
    Send <8002000005>
    Received: ['0x80', '0x2', '0x0', '0x0', '0x5'] (length = 5)
    Second case, without the five zero bytes send after ATR
    ATR
    Received: ['0x3b', '0xfa', '0x13', '0x0', '0x0', '0x81', '0x31', '0xfe', '0x45', '0x4a', '0x43', '0x4f', '0x50', '0x34', '0x31', '0x56', '0x32', '0x32', '0x31', '0x96'] (length = 20)
    * Found header
    * TC1 = 0x81
    J C O P 4 1 V 2 2 1
    Send <00a40000023f00>
    Received: ['0x0', '0xa4', '0x0', '0x0', '0x2', '0x3f', '0x0', '0x0', '0x82', '0x0', '0x82'] (length = 11)
    Send <0a404000a546573744170706c65740>
    Received: ['0x0', '0xa4', '0x4', '0x0', '0xa', '0x54', '0x65', '0x73', '0x74', '0x41', '0x70', '0x70', '0x6c', '0x65', '0x74', '0x0', '0x0', '0x82', '0x0', '0x82'] (length = 20)
    Send <8002000005>
    Received: ['0x80', '0x2', '0x0', '0x0', '0x5'] (length = 5)
    ErikT

    ErikT wrote:Lexdabear,
    Yes, I program the SmartMX using the USB connecter and the put the card hardware into a COMMON(!) card reader. This simply converts serial data from a PC serial port to data to the card. In our application, the controller that's communicating with the card has no 7816 interface, so we have to do that in software. To see what to do on the 7816 port, we use the PC serial port and the card reader hardware.
    At this moment, it seems it has something to do with the software implementation of the 7816 protocol. The applet is not relevant, yet, because it's not even entered.
    Thanx,
    ErikTAh, OK. Your controller does not have the ISO7816 protocol implemented. So you have a lots of work in front of you. Check out ISO7816-4, T=1 .. I assume you have an error in the block structure (e.g. NAD, EDC ..).

  • What is the syntax for set-key RSA-PUB in JCOP Shell?

    I am trying to perform Put Key for the RSA DAP Verification Key using JCOP Shell.
    I have tried variations of the following:
    set-key 115/1/RSA-PUB/[128 byte public key modulus]
    set-key 115/1/RSA-PUB/A001[1 byte public key exponent]A18180[128 byte public key modulus]
    set-key 115/1/RSA-PUB/A001[1 byte public key exponent]A180[128 byte public key modulus]
    But when I send the following command on a SSD with DAP Verification privilege after mutual authentication
    put-key -m add 115/1
    I get jcshell: Unknown exception: java.lang.ArrayIndexOutOfBoundsException: 161 (or 172)
    Thanks,
    Ming

    The format for RSA-PUB is:
    <pubexp length><pubexp><mod length><mod>
    For example:
    115/1/RSA-PUB/0301000180xxxxxx....

  • JSON.parse Response parse failed. I can not open files and JSON.parse Response parse failed. shows up it dosn't happen with I E browser

    JSON.parse Response parse failed.
    I can not open files. And JSON.parse Response parse failed. shows up.
    It doesn't happen when i use the I E browser, so I can't use firefox

    Hi
    I'm trying to make a movie from the JpegImagesToMovie class. But i get a null point exception :(
    java.lang.NullPointerException
         at com.sun.media.multiplexer.video.QuicktimeMux.writeVideoSampleDescription(QuicktimeMux.java:936)
         at com.sun.media.multiplexer.video.QuicktimeMux.writeSTSD(QuicktimeMux.java:925)
         at com.sun.media.multiplexer.video.QuicktimeMux.writeSTBL(QuicktimeMux.java:905)
         at com.sun.media.multiplexer.video.QuicktimeMux.writeMINF(QuicktimeMux.java:806)
         at com.sun.media.multiplexer.video.QuicktimeMux.writeMDIA(QuicktimeMux.java:727)
         at com.sun.media.multiplexer.video.QuicktimeMux.writeTRAK(QuicktimeMux.java:644)
         at com.sun.media.multiplexer.video.QuicktimeMux.writeMOOV(QuicktimeMux.java:582)
         at com.sun.media.multiplexer.video.QuicktimeMux.writeFooter(QuicktimeMux.java:519)
         at com.sun.media.multiplexer.BasicMux.close(BasicMux.java:142)
         at com.sun.media.BasicMuxModule.doClose(BasicMuxModule.java:172)
         at com.sun.media.PlaybackEngine.doClose(PlaybackEngine.java:872)
         at com.sun.media.BasicController.close(BasicController.java:261)
         at com.sun.media.BasicPlayer.doClose(BasicPlayer.java:229)
         at com.sun.media.BasicController.close(BasicController.java:261)
         at movieclear.MovieManager.JpegImagesToMovie.controllerUpdate(JpegImagesToMovie.java:179)
         at com.sun.media.BasicController.dispatchEvent(BasicController.java:1254)
         at com.sun.media.SendEventQueue.processEvent(BasicController.java:1286)
         at com.sun.media.util.ThreadedEventQueue.dispatchEvents(ThreadedEventQueue.java:65)
         at com.sun.media.util.ThreadedEventQueue.run(ThreadedEventQueue.java:92)
    Please please help me out.. I'm totally stuck in this thing. A MOV file is created, but it's a 0kb file.
    Please help me out..
    Sootie.

  • How do you prepersonalize a JCOP Card using JCOP Shell?

    How do you prepersonalize a JCOP Card using JCOP Shell?
    I don't have any clue where to look for this , so I have posted it here.
    Please suggest .

    Hi Shane,
    Actually I have received some Cards which are raw, with no card manager installed in them.
    I also have another set of cards on which I can deploy my applets using the APDU commands.
    I was wondering if I could issue some prepersonalization commands over the JCShell, but did not find anything on this and was looking forward for some suggestions.

  • XOQ-01703: error during parse of build process script: (clear, compile)", "

    Hi All ,
    I was just clearing the dimensions using the below in SQL commandline throwing below error . However this works fine with my another 5 dimensions .Any advice ?
    SQL> exec dbms_cube.build('POSITION using (clear, compile)');
    BEGIN dbms_cube.build('POSITION using (clear, compile)'); END;
    ERROR at line 1:
    ORA-37162: OLAP error
    XOQ-01703: error during parse of build process script: "BUILD POSITION using
    (clear, compile)", ""
    ORA-06512: at "SYS.DBMS_CUBE", line 236
    ORA-06512: at "SYS.DBMS_CUBE", line 280
    ORA-06512: at line 1
    Thanks,
    DxP

    I believe in this case the parser that is parsing the build process script is treating the dimension name "POSITION" as a keyword and not as an OLAP Cube Dimension name. You may wish to rename the dimension to a name other than "POSITION" or double quotes as specified previously.
    Edited by: user713408 on Aug 1, 2011 12:12 PM

  • [JCOP Shell] how to get the result of a script into a variable ?

    Hello all,
    I have a jcsh script that swaps the Two nibbles of an hexadecimal number.
    #swap.jcsh
    X= 0xAB
    R= $(/expr $(/expr ${X} << 4 ) + $(/expr ${X} >> 4 )  )
    /echo 0x${R;h2} the value echoed is 0xBA, right.
    now, I want to replace the X varibale by an argument variable ( ${1} ) and , instead of echoing the result, storing it into another varibale; example :
    Y= swap 0x23this is not working. ;-(
    Does anyone knows how to do it ? is there a "return" equivalent to put at the end of my "swap" script ?
    mkdata are you there ? :)
    Kartagos

    Thank you very much mkdata
    I solve it temporarely by using a global Variable TEMP that will be used by scripts to store the result, then the caller script will simply read the value of this variable (old old school global variable method :) )
    now I'm considering re-writing my libraries
    I knew that there something "DEFUN" but i didn't find any help (when typing "help /error" it talks about something called "defun")
    I think I should write to the JCOP Team to update their docs.
    Regards
    Khaled

  • Jcop shell scripting

    we have a script that we want the jcschell to run automatically
    when clicking on the "running man button".
    is this possible? if we only knew what script it runs to load the applet,
    then we could just add a line to call our script from that one methinks.
    thanks.

    I guess it's c:/JCOPTools22/etc/scripts/capfile-autoload.jcsh (or one of the scripts in this directory).

  • Memory Utilization during XML Parsing - Response time is high

    Slow response time while xml parsing is done.
    Description of the problem:
    During XML parsing, memory is used and discarded so frequently that garbage collection
    is occurring multiple times per minute, impacting performance. In order to better
    understand the source of the memory usage issue, we used JProbe Memory Debugger.
    JProbe Memory Debugger was run in Aggregate mode in order to determine which classes
    were using the most total or aggregate memory (the sum of the memory required
    to instantiate not just a given object, but all the objects it uses.) The result
    was that weblogic.apache. xerces.impl.xs.dom.DocumentImpl and weblogic.apache.xerces.jaxp
    comprise 23.8% and 15.4%, respectively, of total memory on a heap of 121MB. In
    additional tests, the larger the heap, the greater these percentages were.
    This results in slow response time.
    The following are the details of software and Hardware configurations used:
    Server: weblogic 8.1
    OS: Solaris 8
    System Configuration: Sun Microsystems sun4u Sun Fire 6800
    System clock frequency: 150 MHz
    Memory size: 8192 Megabytes

    "Kris" <[email protected]> wrote in message news:40f2fcda$1@mktnews1...
    Sorry, I overlooked it.
    yes we do have 8 GB RAM. And as far as xml usage, we are parsing the xml to DOM
    (including validation) and then applying transformation. But its the parsing stuff
    which is eating the memory.1. Can you run JProbe to find out real CPU utilization/bottlenecks?
    2. Apache Xerses implementation that is used in weblogic has a design
    flaw that results in serialization of memory allocation by the transformer,
    that makes it impossible to use for intense multithreaded transformations.
    Consider using other transformers.
    Regards,
    Slava Imeshev
    >
    >
    "Slava Imeshev" <[email protected]> wrote:
    Please answer my questions.
    Regards,
    Slava Imeshev
    "Krisna" <[email protected]> wrote in message news:40f299ae$1@mktnews1...
    Thanks Slava for youe response. Coming back to response time, thisprocess is part
    of a big task. So i cant really tell what response time i can allocatejust for
    this piece alone. Might be, roughly it should be less than 0.4 seconds.what the
    major concenr is the memory utilization by these packages. So whatmakes it to
    use this kind of memory and whether its a known issue ?
    "Slava Imeshev" <[email protected]> wrote:
    "kris" <[email protected]> wrote in message news:40eaddce$1@mktnews1...
    Slow response time while xml parsing is done.
    Description of the problem:
    During XML parsing, memory is used and discarded so frequently thatgarbage collection
    is occurring multiple times per minute, impacting performance. In
    order
    to better
    understand the source of the memory usage issue, we used JProbe
    Memory
    Debugger.
    JProbe Memory Debugger was run in Aggregate mode in order to determinewhich classes
    were using the most total or aggregate memory (the sum of the memoryrequired
    to instantiate not just a given object, but all the objects it uses.)The result
    was that weblogic.apache. xerces.impl.xs.dom.DocumentImpl and weblogic.apache.xerces.jaxp
    comprise 23.8% and 15.4%, respectively, of total memory on a heap
    of
    121MB. In
    additional tests, the larger the heap, the greater these percentageswere.
    Large heap means longer garbage collections. Anyway, DOM is very heavy
    on memory and you can not escape it. What's is your usage patternfor
    XML
    processing? Do you use XSL?
    This results in slow response time.What do you consider as acceptable/inacceptable responce time?
    The following are the details of software and Hardware configurationsused:
    Server: weblogic 8.1
    OS: Solaris 8
    System Configuration: Sun Microsystems sun4u Sun Fire 6800
    System clock frequency: 150 MHz
    Memory size: 8192 MegabytesDoes this mean you got 8GB RAM on 150Mhz box?
    Regards,
    Slava Imeshev

  • Responsive animation with script - not ok in Wordpress

    Hi,
    I ahve been following Adobe Product Manager Sarah Justine's tutorial (http://sarahjustine.com) on how to make an animation responsive. She has created a script that seems to work perfectly when you resize your browser or use a handheld device. Script is inserted into the "Stage" component:
    (choose compositionReady in dropdown and add code below)
    var stageHeight = sym.$('Stage').height(); // Set a variable for the height of the stage
    sym.$("#Stage").css({ // Set the transform origin so we always scale to the top left corner of the stage
    "transform-origin":"0 0",
    "-ms-transform-origin":"0 0",
    "-webkit-transform-origin":"0 0",
    "-moz-transform-origin":"0 0",
    "-o-transform-origin":"0 0"
    function scaleStage() {
        var stage = sym.$('Stage'); // Set a reusable variable to reference the stage
        var parent = sym.$('Stage').parent(); // Set a reusable variable to reference the parent container of the stage
        var parentWidth = stage.parent().width(); // Get the parent of the stage width
        var stageWidth = stage.width(); // Get the stage width
        var desiredWidth = Math.round(parentWidth * 1); // Set the new width of the stage as it scales
        var rescale = (desiredWidth / stageWidth); // Set a variable to calculate the new width of the stage as it scales
    // Rescale the stage!
               stage.css('transform', 'scale(' + rescale + ')');
        stage.css(  '-o-transform', 'scale(' + rescale + ')');
               stage.css('-ms-transform', 'scale(' + rescale + ')');
        stage.css('-webkit-transform', 'scale(' + rescale + ')');
               stage.css('-moz-transform', 'scale(' + rescale + ')');
        stage.css('-o-transform', 'scale(' + rescale + ')');
        parent.height(stageHeight * rescale); // Reset the height of the parent container so the objects below it will reflow as the height adjusts
    // Make it happen when the browser resizes
    $(window).on('resize', function(){
               scaleStage();
    // Make it happen when the page first loads
    $(document).ready(function(){
        scaleStage();
    My problem is that I use Wordpress and the Edge Animate plug-in and when I insert the animation there the script seems to do nothing. I'm not a coder so I have no idea what might be happening. I'm going to post this on the Wordpress plug-in support page and see is the developer has any ideas. I'll report back about that.
    Any help would be greatly appreciated since this script seems very useful!
    Regards
    Johan

    Ok, so the creator of the script, Sarah Justine came up with this solution:
    I was able to get this to work, but not using shortcodes.
    Follow the same method of uploading an OAM as you normally would. We’re going to use HTML instead of shortcodes, and Edge Suite will still populate your page with the necessary files.
    Instead of the shortcode, use this:
    <div style="width:100%; height:auto"><div id="Stage" class="EDGE-78729757"></div></div>
    You can change the width to be whatever % you want and add some more inline CSS. Grab the class name from whatever Edge Suite reports from the composition.
    I can't get this to work sadly. Continuing discssion with Sarah.
    The WP plug-in developer came up with this change to the actual script:
    The fix is actually quiet simple, just remove the # in front of '#Stage' within
    sym.$(&quot;#Stage&quot;).css so it says sym.$(&quot;Stage&quot;).css. That should fix the whole thing and it should also work with shortcodes. Let me know if that solves it for you.
    I couldn't get this to work either! Discussion continues.
    Johan

  • Passing parameters to shell command within a MAXL script

    Hi all,
    we are trying to run the following from MAXL console
    MAXL> msh script.msh 100 c:\t.txt
    where script.msh has the line:
    shell 'echo $1 >> $2'
    we are looking to add a line with text "100" to the file C:\t.txt but it's actually creating a file called $2 with the text "$1" within it.
    How can we workaround it?
    Thanks

    If I understood well you command line, we would have .log and .err files but .err would be also redirected to .log apart from .err, right?^^^Exactly. That way you can look at either stream, or both. If you think about it, you could test for the existence of any .err file (or come up with your own unique extension for that directory) and flag that after the fact with an email, and attach the specific error and the overall stream. Mind you, given the size of your files, you might want to zip them down first.
    It's the best (or, depending on your outlook, the worst) of all worlds.
    Scripting is one of those things that isn't very sexy, and when it's done well it just fades into the background and doesn't get the credit it deserves. But when it blows up or is kludgy beyond compare it makes everyone's life miserable.
    Regards,
    Cameron Lackpour

  • Passing shell variable to embedded apple script possible?

    The shell script below contains an embedded apple script.  Is it possible to assign the contents of the shell script variable MyShellVar to MyApplVar?
    -Thanks
    #!/bin/bash
    MyShellVar = $(ls /tmp)
    /usr/bin/osascript << EOF
    set MyApplVar to MyShellText    --Don't work!
    tell application "Finder"
       activate
       set result to display dialog MyApplVar buttons {"OK"} default button "OK"
    end tell
    EOF

    Either of these should work:
    #!/bin/bash
    MyShellVar = $(ls /tmp)
    /usr/bin/osascript << EOF
    set MyApplVar to $MyShellVar
    tell application "Finder"
       activate
       set result to display dialog MyApplVar buttons {"OK"} default button "OK"
    end tell
    EOF
    ... or ...
    #!/usr/bin/oascript
    set MyApplVar to do shell script "ls /tmp"
    tell application "Finder"
       activate
       set result to display dialog MyApplVar buttons {"OK"} default button "OK"
    end tell

  • Jcop shell /identify fails

    After seeing another post mention it, I tried /identify on my cards but see an error. Here is the /card ATR and then the /identify error. Have I done something wrong?
    /terminalTerminal:   PCSCJCTerminal
    Status:     Card present, 00000004
    Last error: ERROR
    /cardresetCard with timeout: 0 (ms)
    --Waiting for card...
    ATR=3B 66 00 FF 4A 43 4F 50 33 30                      ;f..JCOP30
    ATR: T=0, N=-1, Hist="JCOP30"
    => 00 A4 04 00 09 A0 00 00 01 67 41 30 00 FF          .........gA0..
    (53114 usec)
    <= 6A 82                                              j.
    Status: File not found
    => 00 A4 04 00 07 A0 00 00 00 03 00 00 00             .............
    (109164 usec)
    <= 6F 19 84 08 A0 00 00 00 03 00 00 00 A5 0D 9F 6E    o..............n
        06 40 51 30 85 30 1A 9F 65 01 FF 90 00             [email protected]....
    Status: No Error
    cm>  /identify
    => 00 A4 04 00 09 A0 00 00 01 67 41 30 00 FF          .........gA0..
    (499948 usec)
    <= 6A 82                                              j.
    Status: File not found
    jcshell: Identification failed - unexpected response (CM=com.ibm.jc.CardManager).

    JCOP30 is the first version (v 2). The IDENTIFY command was implemented in the next version (v 2.2 and 2.2.1).

  • Accessing shell environment variables inside OMBPlus script

    Hi,
    I have a problem accessing an environment variable inside OMBPlus script. I can 'see' the env. var values when using tclsh, but when I use OMBPlus.sh it doesn't work?
    Anybody has an example of how to do this?
    For example: puts $::env(MYVAR)
    Thanks,
    Ed

    Hello!
    Issue the command:
    puts [array names env];
    this will print you the content of the env array which is definitely not the environment variables.
    If you want your environment variable appear in the env tcl variable then you must edit the ombplus.bat file and pass it through a java option like this:
    -DMYENV="%MYENV%" (on windows assuming you declared MYENV).
    Now puts $env(MYENV) will work.
    Regards,
    Robert

  • When I sign into Yahoo mail, I'm getting an error trying to read, move, or delete messages: JSON.parse Response parse failed.

    I have used Firefox for many years and never encountered such a problem. It seems to be only Yahoo mail. The problem started last week and is making it nearly impossible to access my email on this computer. It does not happen on my laptop at home.

    Update
    OK, Today I went ahead & booted & tried again & it worked this time.
    Not sure why it didn't yesterday. Maybe the servers were just overloaded? Several others reported similar.
    Also yesterday when I ran Speedtest it showd download at about 25 mbps, This morning just before I re-started the download it was showing just above 30 mbps.  So maybe the internet was less busy? Or at least the parts between me & the test server.
    & so far it is working ok.

Maybe you are looking for

  • My experience at store #608

    So I pre ordered at store 608 in sanford fl from a guy named mike. He was extremely nice and said on pre order day we had a good shot of getting one since we were early. So I kept waiting on call and just decided to go in Wednesday and find out if we

  • Create a Indesign Plugin - Urgent please

    Hi, I need to create a plugin for indesign. Can anyone please help me out in this issue. I am having eclipse 3.3 and indesign CS3 and CS4. I am following the sdk steps. But i am getting erroe while using dollyxs. I couldnot click OK button as it is t

  • My apple. Version is 4.2.1 and I can not download any thing on it being books, audio books video etc. I mean nothing how can I do it and also upgrade my iPad?

    My iPad can not download any thing at all.

  • Persistent bug

    I've seen this asked and answered several times online and I've tried all the suggested fixes but to no avail. I'll try to be as clear as possible. Whenever I try to make a phone call I get one of several messages. . The process android phone has sto

  • Use of changeip

    Hi there I am switching ISP soon so the external servers need an IP address change which of course is done with the CLI changeip. I have also decided to reconfigure the LAN, moving away from 192.168.1.x to avoid clashes with other networks through VP