It's all about the answers!

Ask a question

JSON script to checkin, comment, & commit change

Jeff Simon (82) | asked Sep 21 '15, 10:51 p.m.
I'm going by the following article:  My CLM implementation is currently only at version 4.0.7, as is this article.

The article offers the following script below.  I'm using JSON (Jackson 2.5.2) on a Windows 2008 server.  Basically Jackson is 3 jar files, set in your CLASSPATH. i've also installed ActiveState Perl.

As in this example, i'm running the command; "  $comment <path to file in workspace>"  or more precisely;
C:\ "Autobuild - edit CommonAssemblyInfo.cs version number" C:\EclipseWorkspaces\Source\CommonAssemblyInfo.cs

I'm looking for some help with the following error;
Argument syntax error: Missing arguments to subcommand "checkin" - path. Try 'lscm help checkin' for more information. malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)") at C:\Jackson-2.5.2\ line 34.

#! /usr/bin/perl

# /*******************************************************************************
#  * Licensed Materials - Property of IBM
#  * (c) Copyright IBM Corporation 2005, 2012. All Rights Reserved.
#  *
#  *******************************************************************************/

# Script to commit files, set comment and complete the change set.
# Script usage: {comment} {file paths...}
# Script usage example: "test comment" .

# Requirements:
#   Install JSON module from

use JSON;

    my $comment = $ARGV[0];
    my $filePattern = "";
    for ($count = 1; $count <= $#ARGV; $count++) {
        if ($count > 1) {
            $filePattern = $filePattern . " ";
        $filePattern = $filePattern . $ARGV[$count];
    # Commit the changes
    my $result = `lscm checkin $filePattern --json`;
    quitOnError($?, $result);
    # Decode the result
    my @json = @{decode_json($result)};

    # Loop through the workspaces->components->outgoingChangesets
    foreach $ws (@json) {
        foreach my $component (@{$ws->{components}}) {
            foreach my $outgoingChangeset (@{$component->{"outgoing-changes"}}) {
                $result = `lscm changeset comment $outgoingChangeset->{"uuid"} "$comment"`;
                quitOnError($?, $result);
                $result = `lscm changeset complete $outgoingChangeset->{"uuid"}`;
                quitOnError($?, $result);
    # Routine that prints the error message and quits
    sub quitOnError {
        my $error_code = shift;
        my $error = shift;
        if ($error_code != 0) {
            print $error . "\n";

Accepted answer

permanent link
Shashikant Padur (4.2k27) | answered Sep 22 '15, 4:40 a.m.
edited Sep 22 '15, 4:43 a.m.
You need to run as follows:
perl <args>
Jeff Simon selected this answer as the correct answer

Jeff Simon commented Sep 22 '15, 4:01 p.m.

Thank you for your help!

One other answer

permanent link
Shashikant Padur (4.2k27) | answered Sep 22 '15, 12:24 a.m.
edited Sep 22 '15, 12:25 a.m.

The error suggests that the file path is not supplied to the 'checkin' command.
Print the contents of the variable 'filePattern' before the line "# Commit the changes" and validate if the supplied file name is printed correctly. You can also print the contents of the variable 'comment'.

Jeff Simon commented Sep 22 '15, 12:49 a.m.

I am it giving to the command as; C:\ "Autobuild - edit CommonAssemblyInfo.cs version number" C:\EclipseWorkspaces\Source\CommonAssemblyInfo.cs, but yes I think it isn't being identified somehow and probably a print output would help.  Can you indulge me though please, i'm not a Perl or JSON (or even java) developer; what is the syntax?

I tried inserting this, but it didn't give me anything;
        $filePattern = $filePattern . $ARGV[$count];
    print $filePattern;

    # Commit the changes

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.