Always got error "/bin/sh: illegal option -." when executing script for lifecycle "run"

0

I have created a component and deployed to a device (Linux/aarch64). A script specified for "run" lifecycle is to execute a jar file, e.g. "java -jar {artifacts:path}/MyJavaApp.jar com.test.Main".

Below is the complete recipe:

{
  "RecipeFormatVersion": "2020-01-25",
  "ComponentName": "com.mitac.ipctestJava",
  "ComponentVersion": "1.0.10",
  "ComponentType": "aws.greengrass.generic",
  "ComponentDescription": "AWS Greengrass IPC test app.",
  "ComponentPublisher": "MiTAC",
  "ComponentConfiguration": {
    "DefaultConfiguration": {
      "Message": "world"
    }
  },
  "Manifests": [
    {
      "Platform": {
        "os": "linux"
      },
      "Lifecycle": {
        "run": {
          "Script": "cd {artifacts:path} && java -jar MyJavaApp.jar com.mitac.ipctestJava.Main"
        }
      },
      "Artifacts": [
        {
          "Uri": "s3://greengrass-component-artifacts-testing/artifacts/com.mitac.ipctestJava/1.0.3/aws-crt-1.0.0-SNAPSHOT.jar",
          "Digest": "IUKar6zGjf1/rEexa1APoG9W3VPG/fCSopbLKnYyTXg=",
          "Algorithm": "SHA-256",
          "Unarchive": "NONE",
          "Permission": {
            "Read": "OWNER",
            "Execute": "OWNER"
          }
        },
        {
          "Uri": "s3://greengrass-component-artifacts-testing/artifacts/com.mitac.ipctestJava/1.0.3/aws-iot-device-sdk-1.0.0-SNAPSHOT.jar",
          "Digest": "qAx+TYwsVXJ2SPKA6+E4/4P+JxGtdMGQi+JHda2cJ/I=",
          "Algorithm": "SHA-256",
          "Unarchive": "NONE",
          "Permission": {
            "Read": "OWNER",
            "Execute": "OWNER"
          }
        },
        {
          "Uri": "s3://greengrass-component-artifacts-testing/artifacts/com.mitac.ipctestJava/1.0.3/gson-2.9.0.jar",
          "Digest": "wAynLo93UkrkP+mN0D6qt+BlWRUybL06AuDJNuoN/J8=",
          "Algorithm": "SHA-256",
          "Unarchive": "NONE",
          "Permission": {
            "Read": "OWNER",
            "Execute": "OWNER"
          }
        },
        {
          "Uri": "s3://greengrass-component-artifacts-testing/artifacts/com.mitac.ipctestJava/1.0.3/MyJavaApp.jar",
          "Digest": "0q7GwQsXB861hlPz0RBa6qNCHEb48HYRdYyS3n2YH5c=",
          "Algorithm": "SHA-256",
          "Unarchive": "NONE",
          "Permission": {
            "Read": "OWNER",
            "Execute": "OWNER"
          }
        },
        {
          "Uri": "s3://greengrass-component-artifacts-testing/artifacts/com.mitac.ipctestJava/1.0.3/run.sh",
          "Digest": "pf17BjH6dede59HCDgNerMoEPIxTwERvw7zqXhqC2Dk=",
          "Algorithm": "SHA-256",
          "Unarchive": "NONE",
          "Permission": {
            "Read": "OWNER",
            "Execute": "OWNER"
          }
        }
      ]
    }
  ],
  "Lifecycle": {}
}

However, I always got error "/bin/sh: illegal option -." in component's log file, and then component finished (exit code of script is 0).

2023-10-05T06:39:39.018Z [WARN] (Copier) com.mitac.ipctestJava: stderr. /bin/sh: illegal option -. {scriptName=services.com.mitac.ipctestJava.lifecycle.run.Script, serviceName=com.mitac.ipctestJava, currentState=RUNNING}
2023-10-05T06:39:39.023Z [INFO] (Copier) com.mitac.ipctestJava: Run script exited. {exitCode=0, serviceName=com.mitac.ipctestJava, currentState=RUNNING}

I have changed content of script, even a simple "ls" command, but all the same error. Is there anyone know the root cause?

Thanks in advance.

  • Can you edit the question to add the recipe, or at least the Run life cycle of the recipe, so we can see the whole syntax?

  • Can you switch to a different shell like - bash?

  • Hi Greg_B, I have added full recipe and error log.

    Hi Saranya, Do you know how to specify different shell only for greengrass service?

    Thanks.

  • Can you confirm if you're able to use sh as expected outside of Greengrass?

Charlie
asked 7 months ago100 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions