Sponsored Content
Top Forums Shell Programming and Scripting Building JSON command with bash script Post 303039151 by stomp on Tuesday 24th of September 2019 11:56:02 AM
Old 09-24-2019
A short comment on debugging:

To check if a function does what it should do, the easiest method is to simply put the function in a small extra program, call it with some valid test data and just print the result to terminal and check if it matches the expectations, or generally speaking, check if the function succesfully executed the expected actions causing the expected results.
This User Gave Thanks to stomp For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Building command line parameters of arbitrary length

I couldn't find an existing thread that addressed this question, so hopefully this isn't redundant with anything previously posted. Here goes: I am writing a C-Shell script that runs a program that takes an arbitrary number of parameters: myprog -a file1 \ -b file2 \ -c file3 ... \ -n... (2 Replies)
Discussion started by: cmcnorgan
2 Replies

2. Shell Programming and Scripting

BASH SCRIPT of LS command

I need help in writing a BASH SCRIPT of ls command. for example: $ ./do_ls.sh files f1.txt f2.jpeg f3.doc $ ./do_ls.sh dirs folder1 folder2 folder3 My attempt: #!/bin/bash # if test $# -d file then echo $dirs else (3 Replies)
Discussion started by: above8k
3 Replies

3. Shell Programming and Scripting

How to define a variable in a BASH script by using a JSON file online?

Hello, I would like to modify an existing script of mine that uses a manually defined "MCVERSION" variable and make it define that variable instead based on this JSON file stored online: https://s3.amazonaws.com/Minecraft.Download/versions/versions.json Within that JSON, I 'm looking for... (4 Replies)
Discussion started by: nbsparks
4 Replies

4. Shell Programming and Scripting

Bash script - cygwin (powershell?) pull from GitHub API Parse JSON

All, Have a weird issue where i need to generate a report from GitHub monthly detailing user accounts and the last time they logged in. I'm using a windows box to do this (work issued) and would like to know if anyone has any experience scripting for GitAPI using windows / cygwin / powershell?... (9 Replies)
Discussion started by: ChocoTaco
9 Replies

5. Shell Programming and Scripting

UNIX or Perl script to convert JSON to CSV

Is there a Unix or Perl script that converts JSON files to CSV or tab delimited format? We are running AIX 6.1. Thanks in advance! (1 Reply)
Discussion started by: warpmail
1 Replies

6. Shell Programming and Scripting

Parsing and Editing a json file with bash script

I am trying to automate editing of a json file using bash script. The file I initially receive is { "appMap": { "URL1": { "name": "a" }, "URL2": { "name": "b" }, "URL3": { "name": "c" }, } WHat I would like to do is replace... (5 Replies)
Discussion started by: Junaid Subhani
5 Replies

7. UNIX for Beginners Questions & Answers

Json field grap via shell script/awk

i have a json data that looks like this: { "ip": "16.66.35.10", "hostname": "No Hostname", "city": "Stepney", "region": "England", "country": "GB", "loc": "51.57,-0.0333", "org": "AS6871 British Telecommunications PLC", "postal": "E1" } im looking for a way to assign... (9 Replies)
Discussion started by: SkySmart
9 Replies

8. Shell Programming and Scripting

JSON structure to table form in awk, bash

Hello guys, I want to parse a JSON file in order to get the data in a table form. My JSON file is like this: { "document":{ "page": }, { "column": } ] }, { ... (6 Replies)
Discussion started by: Gescad
6 Replies

9. Shell Programming and Scripting

Fun with terminal plotting JSON data at the command line

One of the great thing about unix is the ability to pipe multiple programs together to manipulate data. Plain, unstructured text is the most common type of data that is passed between programs, but these days JSON is becoming more popular. I thought it would be fun to pipe together some command... (1 Reply)
Discussion started by: kbrazil
1 Replies

10. UNIX for Beginners Questions & Answers

How to convert any shell command output to JSON format?

Hi All, I am new to shell scripting, Need your help in creating a shell script which converts any unix command output to JSON format output. example: sample df -h command ouput : Filesystem size used avail capacity Mounted /dev/dsk/c1t0d0s0 8.1G 4.0G 4.0G 50% /... (13 Replies)
Discussion started by: balu1234
13 Replies
USERS(5)						FreeRADIUS user authorization file						  USERS(5)

NAME
users - user authorization file for the FreeRADIUS server DESCRIPTION
The users files reside in the files module configuration directory, by default /etc/raddb/mods-config/files/. It contains a series of con- figuration directives which are used by the files module to decide how to authorize and authenticate each user request. Every line starting with a hash sign ('#') is treated as comment and ignored. Each entry of the file begins with a username, followed by a (possibly empty) list of check items, all on one line. The next line begins with a tab, and a (possibly empty) list of reply items. Each item in the check or reply item list is an attribute of the form name = value. Multiple items may be placed on one line, in which case they must be seperated by commas. The reply items may be specified over multiple lines, in which case each line must end with a comma, and the last line of the reply items must not end with a comma. The check items are a list of attributes used to match the incoming request. If the username matches, AND all of the check items match the incoming request, then the reply items are added to the list of attributes which will be used in the reply to that request. This process is repeated for all of the entries in the users file. If the incoming request matches NO entry, then the request is rejected. CAVEATS
The special username DEFAULT matches any usernames. The entries are processed in order, from the top of the users file, on down. If an entry contains the special item Fall-Through = No as a reply attribute, then the processing of the file stops, and no more entries are matched. Any reply item list without any Fall-Through attribute is treated as though it included a Fall-Through = No attribute. If an entry contains the special item Fall-Through = Yes as a reply attribute, then the processing proceeds to the next entry in order. Care should be taken when using Fall-Through. The server should be tested in debugging mode with a number of test requests, in order to verify that the configured entries behave as expected. The special attribute Auth-Type is used to identify the authentication type to be used for that user. See the dictionary file for a list of permitted values for the Auth-Type attribute. Once the users file has been processed, the request is authenticated, using the method given by Auth-Type. OPERATORS
Additional operators other than = may be used for the attributes in either the check item, or reply item list. The following is a list of operators, and their meaning. Attribute = Value Not allowed as a check item for RADIUS protocol attributes. It is allowed for server configuration attributes (Auth-Type, etc), and sets the value of on attribute, only if there is no other item of the same attribute. As a reply item, it means "add the item to the reply list, but only if there is no other item of the same attribute." Attribute := Value Always matches as a check item, and replaces in the configuration items any attribute of the same name. If no attribute of that name appears in the request, then this attribute is added. As a reply item, it has an identical meaning, but for the reply items, instead of the request items. Attribute == Value As a check item, it matches if the named attribute is present in the request, AND has the given value. Not allowed as a reply item. Attribute += Value Always matches as a check item, and adds the current attribute with value to the list of configuration items. As a reply item, it has an identical meaning, but the attribute is added to the reply items. Attribute != Value As a check item, matches if the given attribute is in the request, AND does not have the given value. Not allowed as a reply item. Attribute > Value As a check item, it matches if the request contains an attribute with a value greater than the one given. Not allowed as a reply item. Attribute >= Value As a check item, it matches if the request contains an attribute with a value greater than, or equal to the one given. Not allowed as a reply item. Attribute < Value As a check item, it matches if the request contains an attribute with a value less than the one given. Not allowed as a reply item. Attribute <= Value As a check item, it matches if the request contains an attribute with a value less than, or equal to the one given. Not allowed as a reply item. Attribute =~ Expression As a check item, it matches if the request contains an attribute which matches the given regular expression. This operator may only be applied to string attributes. Not allowed as a reply item. Attribute !~ Expression As a check item, it matches if the request contains an attribute which does not match the given regular expression. This operator may only be applied to string attributes. Not allowed as a reply item. Attribute =* Value As a check item, it matches if the request contains the named attribute, no matter what the value is. Not allowed as a reply item. Attribute !* Value As a check item, it matches if the request does not contain the named attribute, no matter what the value is. Not allowed as a reply item. EXAMPLES
bob Cleartext-Password := "hello" Requests containing the User-Name attribute, with value "bob", will be authenticated using the "known good" password "hello". There are no reply items, so the reply will be empty. DEFAULT Auth-Type = System Fall-Through = Yes For all users reaching this entry, perform authentication against the system, unless Auth-Type has already been set. Also, process any following entries which may match. DEFAULT Service-Type == Framed-User, Framed-Protocol == PPP Service-Type = Framed-User, Framed-Protocol = PPP, Fall-Through = Yes If the request packet contains the attributes Service-Type and Framed-Protocol, with the given values, then include those attributes in the reply. That is, give the user what they ask for. This entry also shows how to specify multiple reply items. See the users file supplied with the server for more examples and comments. HINTS
Run the server in debugging mode (-X), and use the radclient program to send it test packets which you think will match specific entries. The server will print out which entries were matched for that request, so you can verify your expectations. This should be the FIRST thing you do if you suspect problems with the file. Care should be taken when writing entries for the users file. It is easy to misconfigure the server so that requests are accepted when you wish to reject them. The entries should be ordered, and the Fall-Through item should be used ONLY where it is required. Entries rejecting certain requests should go at the top of the file, and should not have a Fall-Through item in their reply items. Entries for specific users, who do not have a Fall-Through item, should come next. Any DEFAULT entries should usually come last, except as fall- through entries that set reply attributes. FILES
/etc/raddb/mods-config/files/ SEE ALSO
radclient(1), radiusd(8), dictionary(5), naslist(5) AUTHOR
The FreeRADIUS team. 04 Jan 2004 USERS(5)
All times are GMT -4. The time now is 04:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy