How to convert following dos batch code to unix shell:-

echo Database username and password will be taken from liquibase.properties file....
setlocal ENABLEEXTENSIONS
for /f "tokens=1* delims==" %%a in (liquibase.properties) do (
if "%%a"=="username" set dbuser=%%b
if "%%a"=="password" set dbpwd=%%b
if "%%a"=="url" set dburl=%%b
)
echo.
echo UserName is:=%dbuser%
echo PassWord is:=%dbpwd%
echo URL is:=%dburl%
echo.
if not %errorlevel%==0 goto ON_FILE_READ_ERROR

Regards
Dattatraya

It is hard to answer your question without knowing what type of shell you need. What will the script be used for and what will it interact with?
For example a config.inc.php file is sometimes used to set variables for a specific php session.

<?php

/**
 * configuration file
 */


// Database connection info
define("CONN_HOST", "localhost", TRUE);
define("CONN_PORT", 3306, TRUE);
define("CONN_USER", "servicedb", TRUE);
define("CONN_PASS", "nokidding", TRUE);
define("CONN_DB", "Service", TRUE);

What you are trying to do is very easy in any of a hundred different ways depending on the type of script needed. Can you tell us a little more about what you are doing or typing to do?

What is the format of the (linux?) version of the liquibase.properties file? Can you specify it or is it already in some format?

What is the actual goal here: Do you want to let the user log in to the database from the command line? Do you want to use PHP as rch1231 suggests? Some other language? If you can control the format of the properties file, then you might have it be syntactically correct for your programming language and just do some equivalent of #include (syntax depends on the language, of course)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.