How to Post in the The UNIX and Linux Forums

Tutorials for how to post and interact in the forums.

Read a json file passed as cmd line argument

json, linux, shell script

👤 Login to reply
Thread Tools Search this Thread Display Modes
Old 06-26-2017
RGRT RGRT is offline
Registered User
Join Date: Jun 2017
Last Activity: 29 June 2017, 2:25 PM EDT
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Read a json file passed as cmd line argument

usage: config.json



    #HOW TO SOURCE THE config.json file? 
    I would like to use the variables in config.josn file to prepare a query and execute in Linux Shell as show below. 

    usr_nm="--username $USR_NM"
    pwd="--password $PWD"

    query= "--connect $host $usr_nm $pwd"
    eval $query

I am new to shell scripting. Please help me on this.

Last edited by RGRT; 06-29-2017 at 02:22 PM.. Reason: Update
Sponsored Links
Old 06-26-2017
vgersh99's Unix or Linux Image
vgersh99 vgersh99 is offline Forum Advisor  
Forum Advisor
Join Date: Feb 2005
Last Activity: 19 July 2018, 12:50 AM EDT
Location: Foxborough, MA
Posts: 8,312
Thanks: 257
Thanked 839 Times in 783 Posts
see if that helps:
awk -F '("|:)' 'NF>1 {print $2,$5}' config.json

Sponsored Links
Old 06-27-2017
RudiC RudiC is offline Forum Staff  
Join Date: Jul 2012
Last Activity: 18 July 2018, 4:17 PM EDT
Location: Aachen, Germany
Posts: 13,073
Thanks: 449
Thanked 4,014 Times in 3,691 Posts
I'm afraid there quite some open questions, like
- which combinations from that config file entries do you need,all permutations from the 10 - 15 entries?
- which section of the file should be used, or is there just one?
- how are you going to use the results, source them in
- are you sure the host part and the DB part will be joined by a / ?
Sponsored Links
👤 Login to reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl Code to change file delimiter (passed as argument) to bar delimiter JPB1977 Shell Programming and Scripting 2 01-05-2014 09:23 AM
Variable passed as argument anil510 Shell Programming and Scripting 3 03-03-2013 04:02 AM
shell script for ftp files passed in command line argument rateeshkumar Shell Programming and Scripting 5 03-23-2011 10:27 PM
File not recognized when passed as argument michaelrozar17 Shell Programming and Scripting 9 08-14-2010 02:17 AM
how to print all argument passed RahulJoshi Shell Programming and Scripting 2 10-13-2008 05:38 PM

All times are GMT -4. The time now is 01:50 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
Show Password

Not a Forum Member?
Forgot Password?