The beginner shell, takes the variables in the environment-variable-mac.ini file and the templates and files in the setting.ini.

Novice shell, I want to read the variables in the environment-variable-mac.ini file and the templates in the setting.js, and then put both the variables and the setting.ini file in a newly generated setting.js file, both of which are in the configuration directory

environment-variable-mac.ini

UNIVER_USER_LOGIN="http://127.0.0.1/api/login"
UNIVER_SEARCH_ORDINARY="http://127.0.0.1/api/search/common"
UNIVER_SEARCH_LABEL="http://127.0.0.1/api/search/common"
UNIVER_SEARCH_VIDEO="http://127.0.0.1/api/search/common"
UNIVER_TASK_MANAGER="http://127.0.0.1/api/task/manager"
UNIVER_PROJECR_URL="67.110.220.11"
UNIVER_PROJECR_PORT=777778888

setting.ini


/**
 * environment
 * 
 * 
 */

var ENV = (function(){

    return {

        pythonAPI: {
            userLogin : "$UNIVER_USER_LOGIN",
            video: "", //
            searchOrdinary: "$UNIVER_USER_LOGIN, 
            searchLabel: "$UNIVER_USER_LOGIN",
            searchVideo : "$UNIVER_USER_LOGIN", 
            taskManager: "UNIVER_TASK_MANAGER", 
            domainName: "UNIVER_PROJECR_PORT", // 
            domainPort: $UNIVER_USER_LOGIN
        }

    }
})();

I want the content in my setting.js file to be like this


/**
 * environment
 * 
 * 
 */

var ENV = (function(){

    return {

        pythonAPI: {
            userLogin : "http://127.0.0.1/api/login",
            video: "", //
            searchOrdinary: "http://127.0.0.1/api/search/common", // 
            searchLabel: "http://127.0.0.1/api/search/common",
            searchVideo : "http://127.0.0.1/api/search/common", // 
            taskManager: "http://127.0.0.1/api/task/manager", // 
            domainName: "67.110.220.11", // 
            domainPort: 777778888// 
        }

    }
})();

my script goes like this


-sharp!/bin/bash

awk -F "=" "BEGIN {print "{"} {print "\t"$1":"$2","} END{print "}"}" environment-variable-mac.ini > setting.js


awk -F "=" "BEGIN {print "{"} {print "\t"$1":"$2","} END{print "}"}" setting.ini > setting.js

but cannot generate the file I want

Apr.11,2021

declare that I don't usually use shell, to learn and use it, so I don't guarantee the best method.
the absence of $ in front of several variables in the setting.ini you gave cannot be replaced

Save the following file as process.sh, to grant executable permissions, and then execute it in the setting.ini, environment-variable-mac.ini sibling directory.

-sharp!/bin/sh
cp ./setting.ini ./setting.js
for line in $(cat environment-variable-mac.ini)
do
    name="$"$(echo $line | awk -F '=' '{print $1}')
    val=$(echo $line | awk -F '=' '{print $2}')
    val=$(echo $val | sed "s/'//g")

    sed -i ".bak" "s-sharp$name-sharp$val-sharpg" ./setting.js
done
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e495a7-444b3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e495a7-444b3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?