I need to extract text between two single quotes (") into the field "my_description":
description="Env: Application: Upgrade App for SNOW from 1.0.0 to 2.0.0 on server myserver.mydomain.com. This is being done to support the upcoming upgrade to the Patch 3 release.
All changes and post-implementation verification will be done.
This has been tested successfully in lower environments."
I don't know what you mean with the
into the field "my_description"
part, but you can find the answer here
RegEx: Grabbing values between quotation marks
Related
I'm testing a python script to retrieve the software version from Cisco gear. The script works fine connecting to the remote device and obtaining the information required. The problem starts when I try to filter some unwanted information from pexpect output. The function's code in charge of getting the vesion information is as follows:
def get_version_info(session):
session.sendline('show version | include Version')
result = session.expect(['>', pexpect.TIMEOUT])
# Extract the 'version' part of the output
version_output_lines = session.before.splitlines()
version = version_output_lines[4].strip("'")
print("--- got version: ", version)
return version
The required information from the raw output after spliting lines (line 5 in code) was placed in the following list:
[b' ', b'', b'HOSTNAME#show version | include Version', b'Cisco IOS XE Software, Version 16.09.02', b'Cisco IOS Software [Fuji], ASR1000 Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.9.2, RELEASE SOFTWARE (fc4)', b'licensed under the GNU General Public License ("GPL") Version 2.0. The', b'software code licensed under GPL Version 2.0 is free software that comes', b'GPL code under the terms of GPL Version 2.0. For more details, see the', b'HOSTNAME#']
All I need from the above output is "Version 16.9.2", the rest needs to be stripped out.
I tried to isolate element 4 of the list (version_output_lines[4]) and use the strip function, but it keeps sending an error:
TypeError: a bytes-like object is required, not 'str'
So I'd like to know if you have a better idea on how to strip all the unwanted information from the list and only leave the Version info as mentioned before.
Thanks.
The .strip() method exists for type strings and also for type bytes. When applied to bytes it needs a bytes parameter instead of the string "'" you supplies. So use .strip(b"'").
You can also decide to have pexpect encode the bytes into strings by using, for example, encoding='utf8' as a parameter in the spawn() call.
I am using the downloading latest artifact feature.
For me it is not clear, how the job name I need to pass is created: my job name contains e.g. spaces, equal signs and brackets:
build win: [USE_PYTHON=ON]
I know that spaces are replaced by +-signs but what about the others characters?
Changing the job name is not an option because I use the matrix-feature and it creates names like these.
Thanks a lot for your help!
Example ci yaml:
build win:
...
parallel:
matrix:
- USE_PYTHON: ["USE_PYTHON=ON", "USE_PYTHON=OFF"]
You can use ASCII encoding like for space %20.
Find them here
https://www.w3schools.com/tags/ref_urlencode.ASP
I am using postgres database, I have a table called names which has a column named 'info' which is of type json. I am adding
{ "info": "security" , description : "Sednit update: Analysis of Zebrocy: The Sednit group \u2013 also known as APT28, Fancy Bear, Sofacy or STRONTIUM \u2013 is a group of attackers operating since 2004, if not earlier, and whose main objective is to steal confidential information from specific targets.\n\nToward the end of 2015, we started seeing a new component deployed by the group; a downloader for the main Sednit backdoor, Xagent. Kaspersky mentioned this component for the first time in 2017 in their APT trend report and recently wrote an article where they quickly described it under the name Zebrocy.\n\nThis new component is a family of malware, comprising downloaders and backdoors written in Delphi and AutoIt. These components play the same role in the Sednit ecosystem as Seduploader; that of first-stage malware."}
Here I am using node js, with sequelize as orm. When I save it in table. I see "\\n" for "\n" and "\\u" for \u. Can anyone help me to avoid escaping characters while saving to table.
I see \n for \n and \u for \u.
In your json description is type of string , so it will convert the new line/enter to \n that the default behavior , or else you will not get the new line / enter when you try to fetch the data again.
And \u is for unicode , you might be saving some smily or special character so that will be converted to such strings.
So there is no bug , this is how it works.
I have a file with lines that all begin with a date, followed by a tab, followed by a random number of words and spaces—some of which include numbers. For example:
20140217 iPhone Upgrade Available
20131101 Job Application Due
20131219 Renew or return all library books
20131114 Pay cell phone bill
I'm trying to sort this file by the date string and only the date string.
As per this thread, I've tried all kinds of combinations of sort -t$'\t' and -k1, but I keep getting garbled results.
Any help would be much appreciated. Also, it IS possible for me to replace that tab with a space or another character, if that would help for any reason.
you may want to try
sort -n -k1,1 file
output is
20131101 Job Application Due
20131114 Pay cell phone bill
20131219 Renew or return all library books
20140217 iPhone Upgrade Available
You can use it like this:
sort -k1,1 file
here i am using set numCut [scan $inline1 "%d"] in tcl script for linux server, but after execting script it's showing below error
`different numbers of variable names and field specifiers` variable $inline1
value is `2) "NYMEX UTBAPI Worker" (NYMEX UTBAPI Poller): STOPPED`
i searched in google for this then i got below
`
0x1771b07c tcl_s_cmdmz_diff_num_var_field
Text: Different numbers of variable names and field specifiers
Severity: tcl_c_general_error
Component: tcl / tcl_s_general
Explanation: The scan command detected that the number of variable names
provided differs from the number of field specifiers provided.
Action: Verify that the number of variable names is the same as the number of
field specifiers.
`
here i got the above description.
Can anyone help me out how to solve this issue?
thanks in advance...
The ability to return the matched fields was added in Tcl 8.5. Prior to that, you had to supply a variable for each field that you had in the scan, and the result would be the number of fields matched (and it still is if you provide variable names).
Change:
set numCut [scan $inline1 "%d"]
to:
scan $inline1 "%d" numCut
Or switch to a more recent version of Tcl if you can, as 8.4 is almost out of its extended support period. (There will be a final patch release this summer to address some minor issues with build problems on recent systems, but that's it. We won't support it after that.)
I think that the Tcl error message is telling you that the number of specifiers in your format string %d is different to the number of variables in your Tcl command scan $inline1 "%d".
So, you have one format specifier, and no variables and that's what the Tcl interpreter is telling you.
Try changing your command to scan $inline1 "%d" numCut and see if that works any better.