Sponsored Content
Full Discussion: Shell scripting with JQ help
Top Forums UNIX for Beginners Questions & Answers Shell scripting with JQ help Post 303043117 by DSFX on Saturday 18th of January 2020 07:36:01 PM
Old 01-18-2020
Shell scripting with JQ help

Evening all,

this is my first go at any bash scripting and i'm struggling with handling jquery. I've got the jq library installed and working. i'm working out of Ubuntu and my JQuery looks like this, some info is censored with #.

Code:
{
  "description": "some description 1",
  "fixed_version": "######",
  "link": "https://security-tracker.debian.org/tracker/CVE-#######",
  "name": "CVE-######",
  "package_name": "some package 1",
  "package_version": "####",
  "score": 4.6,
  "score_v3": 9.1,
  "severity": "Medium",
  "vectors": "AV:L/AC:L/Au:N/C:P/I:P/A:P",
  "vectors_v3": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N"
}
{
  "description": "some description 2",
  "fixed_version": "#######",
  "link": "https://security-tracker.debian.org/tracker/CVE-#######",
  "name": "CVE-######",
  "package_name": "some package 2",
  "package_version": "#####",
  "score": 4.6,
  "score_v3": 9.1,
  "severity": "Medium",
  "vectors": "AV:L/AC:L/Au:N/C:P/I:P/A:P",
  "vectors_v3": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N"
}

What i'd like to do is iterate through this so like so....
Code:
vulnerabilities=$(<"$WorkingDirectory"/vulnerabilities.txt) 
echo $vulnerabilities | $JSONParser -r '.[0].description'

This is the error i'm getting
Code:
jq: error (at <stdin>:1): Cannot index object with number

I've got a web dev background and a bit of PS. Dealing with JQuery in Shell so far has been a nightmare. Can anybody tell me what i'm doing wrong???

Thanks,
DSFX

Last edited by Scrutinizer; 01-18-2020 at 08:45 PM.. Reason: quote tags -> code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies

2. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

3. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

4. Android

Android Scripting Environment: Shell Scripting and Android

I just upgraded to Android 2.2 from 2.1. The GPS issue that was troublesome in 2.1 seems to have been fixed. Some of web browsing seems faster, but it could just be my connection is better today ;) Flash works in some browsers but not very good and it is too slow for Flash apps designed for... (0 Replies)
Discussion started by: Neo
0 Replies

5. What is on Your Mind?

Shell Scripting vs Perl scripting

Gents, I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Discussion started by: Pouchie1
2 Replies

6. Web Development

Perl scripting or shell scripting?

i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

7. UNIX for Dummies Questions & Answers

Shell Scripting

Hey I have a data in the file named as outputFile.txt. The data is in the format 123456,12345678912345,400,09/09/09,INACTIVE. I want this output without commas ie 12345612345678912345400090909INACTIVE. Please tell me what to do and clear explain all the terms, as I am new to it. (6 Replies)
Discussion started by: sampandey31
6 Replies

8. Shell Programming and Scripting

Shell scripting

Hi, if in a network there are lots of PCs connected with either windows or linux as operating system.Then what will be the shell script for the same and also if the PC has linux in it then we have to find if it is occupied or unoccupied. If the PC has windows in it then we have to find if it is... (6 Replies)
Discussion started by: akansha singh
6 Replies

9. Shell Programming and Scripting

help me in Shell Scripting

Hi there please have a look at the code..i want to create Using a named pipe. Run a find in the background starting in the working directory While this is happening wait for input from the user to ask him which file to find. If the user does not enter any data in 10 seconds ask the user again.... (1 Reply)
Discussion started by: kattak1511
1 Replies

10. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies
NPM(1)                                                                                                                                      NPM(1)

NAME
npm - javascript package manager SYNOPSIS
npm <command> [args] VERSION
6.7.0 DESCRIPTION
npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency conflicts intelligently. It is extremely configurable to support a wide variety of use cases. Most commonly, it is used to publish, discover, install, and develop node programs. Run npm help to get a list of available commands. IMPORTANT
npm is configured to use npm, Inc.'s public registry at https:// by default. Use of the npm public registry is subject to terms of use available at https:// You can configure npm to use any compatible registry you like, and even run your own registry. Use of someone else's registry may be gov- erned by their terms of use. INTRODUCTION
You probably got npm because you want to install stuff. Use npm install blerg to install the latest version of "blerg". Check out npm help npm-install for more info. It can do a lot of stuff. Use the npm search command to show everything that's available. Use npm ls to show everything you've installed. DEPENDENCIES
If a package references to another package with a git URL, npm depends on a preinstalled git. If one of the packages npm tries to install is a native node module and requires compiling of C++ Code, npm will use node-gyp https://github.com/TooTallNate/node-gyp for that task. For a Unix system, node-gyp https://github.com/TooTallNate/node-gyp needs Python, make and a buildchain like GCC. On Windows, Python and Microsoft Visual Studio C++ are needed. Python 3 is not supported by node-gyp https://github.com/TooTallNate/node-gyp. For more information visit the node-gyp repository https://github.com/TooTallNate/node-gyp and the node-gyp Wiki https://github.com/TooTallNate/node-gyp/wiki. DIRECTORIES
See npm help 5 npm-folders to learn about where npm puts stuff. In particular, npm has two modes of operation: o global mode: npm installs packages into the install prefix at prefix/lib/node_modules and bins are installed in prefix/bin. o local mode: npm installs packages into the current project directory, which defaults to the current working directory. Packages are installed to ./node_modules, and bins are installed to ./node_modules/.bin. Local mode is the default. Use -g or --global on any command to operate in global mode instead. DEVELOPER USAGE
If you're using npm to develop and publish your code, check out the following help topics: o json: Make a package.json file. See npm help 5 package.json. o link: For linking your current working code into Node's path, so that you don't have to reinstall every time you make a change. Use npm link to do this. o install: It's a good idea to install things if you don't need the symbolic link. Especially, installing other peoples code from the reg- istry is done via npm install o adduser: Create an account or log in. Credentials are stored in the user config file. o publish: Use the npm publish command to upload your code to the registry. CONFIGURATION
npm is extremely configurable. It reads its configuration options from 5 places. o Command line switches: Set a config with --key val. All keys take a value, even if they are booleans (the config parser doesn't know what the options are at the time of parsing). If no value is provided, then the option is set to boolean true. o Environment Variables: Set any config by prefixing the name in an environment variable with npm_config_. For example, export npm_con- fig_key=val. o User Configs: The file at $HOME/.npmrc is an ini-formatted list of configs. If present, it is parsed. If the userconfig option is set in the cli or env, then that will be used instead. o Global Configs: The file found at ../etc/npmrc (from the node executable, by default this resolves to /usr/local/etc/npmrc) will be parsed if it is found. If the globalconfig option is set in the cli, env, or user config, then that file is parsed instead. o Defaults: npm's default configuration options are defined in lib/utils/config-defs.js. These must not be changed. See npm help 7 npm-config for much much more information. CONTRIBUTIONS
Patches welcome! If you would like to contribute, but don't know what to work on, read the contributing guidelines and check the issues list. o CONTRIBUTING.md https://github.com/npm/cli/blob/latest/CONTRIBUTING.md o Bug tracker https://npm.community/c/bugs o Support tracker https://npm.community/c/support BUGS
When you find issues, please report them: o web: https://npm.community/c/bugs Be sure to follow the template and bug reporting guidelines. You can also ask for help in the support forum https://npm.community/c/support if you're unsure if it's actually a bug or are having trouble coming up with a detailed reproduction to report. AUTHOR
Isaac Z. Schlueter http://blog.izs.me/ :: isaacs https://github.com/isaacs/ :: @izs https://twitter.com/izs :: i@izs.me SEE ALSO
o npm help help o README o npm help 5 package.json o npm help install o npm help config o npm help 7 config o npm help 5 npmrc o npm help 7 index January 2019 NPM(1)
All times are GMT -4. The time now is 01:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy