[Backlogmanager] [FIWARE-JIRA] (HELP-19039) [fiware-stackoverflow] ' : not a valid identifiert: ` when running bash create command in windows

Jason Fox (JIRA) jira-help-desk at jira.fiware.org
Mon Dec 20 09:13:00 CET 2021


    [ https://jira.fiware.org/browse/HELP-19039?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=115440#comment-115440 ] 

Jason Fox commented on HELP-19039:
----------------------------------

User was attempting to use PowerShell to run Bash commands. They were advised to use a bash shell in the comments.

> [fiware-stackoverflow] ': not a valid identifiert: ` when running bash create command in windows
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HELP-19039
>                 URL: https://jira.fiware.org/browse/HELP-19039
>             Project: Help-Desk
>          Issue Type: Monitor
>          Components: FIWARE-TECH-HELP
>            Reporter: Backlog Manager
>            Assignee: Jason Fox
>              Labels: bash, docker-compose, fiware, powershell
>
> Created question in FIWARE Q/A platform on 13-12-2021 at 08:12
> {color: red}Please, ANSWER this question AT{color} https://stackoverflow.com/questions/70331540/not-a-valid-identifiert-when-running-bash-create-command-in-windows
> +Question:+
> ': not a valid identifiert: ` when running bash create command in windows
> +Description:+
> I'm trying to implement this tutorial, but when I try to run "./services create" command in powershell (in windows 10) I get this error :
> ': not a valid identifiert: `
> ': not a valid identifiert: `
> ': not a valid identifiert: `
> ': not a valid identifiert: `
> ': not a valid identifiert: `
> ': not a valid identifiert: `
> ': not a valid identifiert: `
> ': not a valid identifiert: `
> ': not a valid identifiert: `
> I've converted the carriage return in notepad++ (Edit -> EOL conversion -> Unix (LF)) before running the code. before this conversion I was getting this error :
> ./services: line 16: $'\r': command not found
> : invalid option 17: set: -
> set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
> ./services: line 18: $'\r': command not found
> ./services: line 30: syntax error near unexpected token `$'{\r''
> '/services: line 30: `loadData () {
> you can also see the bash script here :
> #!/bin/bash
> #
> #  Command Line Interface to start all services associated with the Tutorial
> #
> #  For this tutorial the commands are merely a convenience script to run docker or docker-compose
> #
> #  Each services script can be run using either docker-compose (the external tool with the hyphen -) 
> #  or docker compose (the newer version directly bundled with Docker with a space )
> #
> #  if you start up with the following command:
> #
> #  ./services start legacy
> #
> # This will force the script to use docker-compose which may be more reliable in 
> # some cases (or if an older version of Docker is being used)
> set -e
> dockerCmd="docker compose"
> if (( $# == 2 )); then
>     dockerCmd="docker-compose"
> fi
> if (( $# < 1 )); then
>     echo "Illegal number of parameters"
>     echo "usage: services [create|start|stop]"
>     exit 1
> fi
> loadData () {
>     docker run --rm -v $(pwd)/import-data:/import-data \
>         --network fiware_default \
>         -e ORION_PORT="${ORION_PORT}" \
>         -e TUTORIAL_APP_PORT="${TUTORIAL_APP_PORT}" \
>         --entrypoint /bin/ash curlimages/curl import-data
>     waitForIoTAgent
>     docker run --rm -v $(pwd)/provision-devices:/provision-devices \
>         --network fiware_default \
>         -e ORION_PORT="${ORION_PORT}" \
>         -e TUTORIAL_APP_PORT="${TUTORIAL_APP_PORT}" \
>         -e TUTORIAL_DUMMY_DEVICE_PORT="${TUTORIAL_DUMMY_DEVICE_PORT}" \
>         -e IOTA_NORTH_PORT="${IOTA_NORTH_PORT}" \
>         --entrypoint /bin/ash curlimages/curl provision-devices
>     echo ""
> }
> waitForKeyrock () {
>     echo -e "⏳ Waiting for \033[1;31mKeyrock\033[0m to be available\n"
>     
>     while ! [ `docker inspect --format='{{.State.Health.Status}}' fiware-keyrock` == "healthy" ]
>     do 
>         echo -e "Keyrock HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://localhost:3005/version'` " (waiting for 200)"
>         sleep 5
>     done
>     echo -e " \033[1;32mdone\033[0m"
> }
> waitForWirecloud () {
>     echo -e "⏳ Waiting for \033[1;35mWirecloud\033[0m to be available\n"
>     
>     while [ `curl -s -o /dev/null -w %{http_code} 'http://localhost:8000/api/features'` -eq 000 ]
>     do 
>         echo -e "Wirecloud HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://localhost:8000/api/features'` " (waiting for 200)"
>         sleep 5
>     done
>     echo -e " \033[1;32mdone\033[0m"
> }
> waitForMongo () {
>     echo -e "\n⏳ Waiting for \033[1mMongoDB\033[0m to be available\n"
>     while ! [ `docker inspect --format='{{.State.Health.Status}}' db-mongo` == "healthy" ]
>     do 
>         sleep 1
>     done
> }
> waitForOrion () {
>     echo -e "\n⏳ Waiting for \033[1;34mOrion\033[0m to be available\n"
>     while ! [ `docker inspect --format='{{.State.Health.Status}}' fiware-orion` == "healthy" ]
>     do
>       echo -e "Context Broker HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://localhost:1026/version'` " (waiting for 200)"
>       sleep 1
>     done
> }
> waitForIoTAgent () {
>     echo -e "\n⏳ Waiting for \033[1;36mIoT-Agent\033[0m to be available\n"
>     while ! [ `docker inspect --format='{{.State.Health.Status}}' fiware-iot-agent` == "healthy" ]
>     do 
>       echo -e "IoT Agent HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://localhost:4041/version'` " (waiting for 200)"
>       sleep 1
>     done
> }
> addDatabaseIndex () {
>     printf "Adding appropriate \033[1mMongoDB\033[0m indexes for \033[1;34mOrion\033[0m  ..."
>     docker exec  db-mongo mongo --eval '
>     conn = new Mongo();db.createCollection("orion");
>     db = conn.getDB("orion");
>     db.createCollection("entities");
>     db.entities.createIndex({"_id.servicePath": 1, "_id.id": 1, "_id.type": 1}, {unique: true});
>     db.entities.createIndex({"_id.type": 1}); 
>     db.entities.createIndex({"_id.id": 1});' > /dev/null
>     docker exec  db-mongo mongo --eval '
>     conn = new Mongo();db.createCollection("orion-openiot");
>     db = conn.getDB("orion-openiot");
>     db.createCollection("entities");
>     db.entities.createIndex({"_id.servicePath": 1, "_id.id": 1, "_id.type": 1}, {unique: true});
>     db.entities.createIndex({"_id.type": 1}); 
>     db.entities.createIndex({"_id.id": 1});' > /dev/null
>     echo -e " \033[1;32mdone\033[0m"
>     printf "Adding appropriate \033[1mMongoDB\033[0m indexes for \033[1;36mIoT-Agent\033[0m  ..."
>     docker exec  db-mongo mongo --eval '
>     conn = new Mongo();
>     db = conn.getDB("iotagentul");
>     db.createCollection("devices");
>     db.devices.createIndex({"_id.service": 1, "_id.id": 1, "_id.type": 1});
>     db.devices.createIndex({"_id.type": 1}); 
>     db.devices.createIndex({"_id.id": 1});
>     db.createCollection("groups");
>     db.groups.createIndex({"_id.resource": 1, "_id.apikey": 1, "_id.service": 1});
>     db.groups.createIndex({"_id.type": 1});' > /dev/null
>     echo -e " \033[1;32mdone\033[0m"
> }
> startContainers () {
>     echo ""
>     export IDM_HTTPS_ENABLED="$1" 
>     ${dockerCmd} up -d --remove-orphans
>     echo ""
> }
> stoppingContainers () {
>     CONTAINERS=$(docker ps -aq)
>     if [[ -n $CONTAINERS ]]; then 
>         echo "Stopping containers"
>         docker rm -f $CONTAINERS
>     fi
>     VOLUMES=$(docker volume ls -qf dangling=true) 
>     if [[ -n $VOLUMES ]]; then 
>         echo "Removing old volumes"
>         docker volume rm $VOLUMES
>     fi
> }
> command="$1"
> case "${command}" in
>     "help")
>         echo "usage: services [create|start|stop]"
>         ;;
>     "start")
>         export $(cat .env | grep "#" -v)
>         stoppingContainers
>         echo -e "Starting containers: \033[1;34mOrion\033[0m, \033[1;36mIoT-Agent\033[0m, \033[1;31mKeyrock\033[0m, \033[1;35mWirecloud\033[0m, \033[1mTutorial\033[0m"
>         echo -e "Along with the following databases: \033[1mMongoDB\033[0m, \033[1mPostGres\033[0m and \033[1mMySQL\033[0m"
>         echo -e "and microservices: \033[1mElasticSearch\033[0m, \033[1mMemCache\033[0m and \033[1;35mNGSI Proxy\033[0m\n"
>         echo -e "- \033[1;34mOrion\033[0m is the context broker"
>         echo -e "- \033[1;36mIoT-Agent\033[0m is configured for the UltraLight Protocol"
>         echo -e "- \033[1mTutorial\033[0m acts as a series of dummy IoT Sensors over HTTP"
>         echo -e "- \033[1;31mKeyrock\033[0m is an Identity Management Front-End"
>         echo -e "- \033[1;35mWirecloud\033[0m is a Dashboard Utility"
>         echo -e "- \033[1;35mNGSI Proxy\033[0m creates a server that is capable of redirecting Orion notifications to web pages"
>         startContainers false
>         waitForMongo
>         addDatabaseIndex
>         waitForOrion
>         loadData
>         waitForWirecloud
>         waitForKeyrock
>         echo -e "Now open \033[4mhttp://localhost:8000\033[0m"
>         ;;
>     "stop")
>         export $(cat .env | grep "#" -v)
>         stoppingContainers
>         ;;
>     "create")
>         export $(cat .env | grep "#" -v)
>         echo "Pulling Docker images"
>         docker pull curlimages/curl
>         ${dockerCmd} pull 
>         ;;
>     *)
>         echo "Command not Found."
>         echo "usage: services [create|start|stop]"
>         exit 127;
>         ;;
> esac



--
This message was sent by Atlassian JIRA
(v6.4.1#64016)


More information about the Backlogmanager mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy