scripting

Shell script to grep string and its value and produce output in another file

允我心安 提交于 2020-01-06 05:46:10
问题 I need to grep value of ErrCode, ErrAttkey and ErrDesc from the below Input file. and need to display as below in another file How can i do this using shell script? Required output ErrCode|ErrAtkey|ErrDesc 003010|A3|The Unique Record IDalreadyExists 008024|A8|Prepaid / Postpaid not specified Input File <TariffRecords><Tariff><UniqueID>TT07PMST0088</UniqueID><SubStat>Failure</SubStat><ErrCode>003010</ErrCode><ErrAttKey>A3</ErrAttKey><ErrDesc>The' Unique Record ID already 'Exists</ErrDesc><

KornShell: Variable assigned “000010” converted to 8 instead of 10.

删除回忆录丶 提交于 2020-01-06 04:51:14
问题 I have a fixed length string which is a number. When I assign the string to a variable it is getting assigned 8 instead of 10. Why? How do I stop it? $ i=10 $ ((i=i+1)) $ echo $i 11 # Right answer $ i=000010 $ ((i=i+1)) $ echo $i 9 # Wrong answer Update: The answers confirm that the number is being converted to octal and that the leading zeros need to be removed. Here is the sed command for that. echo "000010" | sed 's/0*//' 回答1: That's because a leading 0 means that the constant is octal

What's the best way to use username/password auth in a Ruby script in OS X?

ぃ、小莉子 提交于 2020-01-06 04:50:06
问题 I am working on an automated backup script. This script needs to download an HTTP resource using a username and password. At the moment, the auth credentials are in cleartext, which is obviously not ideal from a security point of view. I recently discovered the security utility on OS X after reading this blog post. security gives you keychain access from the command line. The OS X Keychain allows you to specify applications that are allowed access to a specific password, but it turns out that

Bash string concatenation producing weird results [duplicate]

强颜欢笑 提交于 2020-01-06 04:36:08
问题 This question already has answers here : Concatenating strings in bash overwrites them (4 answers) Closed 2 years ago . My bash code file.sh : username=$1 pkgpath="/home/${username}_tmp.txt" echo $username echo $pkgpath Now running the script with the command bash file.sh abc should produce the result : abc /home/abc_tmp.txt But the output I'm getting is : abc _tmp.txtc Can someone explain why is this behavior occurring and how to obtain the desired result ? EDIT I'd like to mention that

Grepping `reg query` result value?

强颜欢笑 提交于 2020-01-06 04:27:11
问题 Consider the following result from a hypothetical reg query : ..>reg query HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MediaPlayer /v "I nstallation Directory" HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MediaPlayer Installation Directory REG_EXPAND_SZ %ProgramFiles%\Windows Media Play er How do I grep the output so that I can assign the actual value of the setting ( %ProgramFiles%\... ) into a variable (or temp file)? 回答1: example for batch files: @FOR /F "tokens=2* " %%A IN (

Calling Redis zunionstore from Lua with variable KEYS

℡╲_俬逩灬. 提交于 2020-01-06 02:34:11
问题 I have a lua script that needs to call a zunionstore on a variable number of keys. I'm trying to execute the following code: local args = redis.call("zrange", "weight", 0, -1, "WITHSCORES") local r,w local count = 0 local cmd = ' ' for i=1,#args,2 do cmd = cmd .. args[i] .. ":weight " -- building up a list of zsets count = count + 1 end redis.call("zunionstore", "p2_test_set", count, cmd) The important lines being: cmd = cmd .. args[i] .. ":weight " Which builds the list of keys, and the

Netstat with WMI and VBScript

℡╲_俬逩灬. 提交于 2020-01-06 02:12:12
问题 I am working on a project where I need to modify a script used for network documentation. The current script that we use is a modified version of SYDI, found here. What I would like to do is add to this script the ability to execute a netstat -an and have it returned with the rest of the report. I was curious if anyone has used WMI and VBScript to return netstat information and how it might be able to be incorporated into this script. NOTE: I am not trying to promote a product and I am not

Running Database scripts in C#

我怕爱的太早我们不能终老 提交于 2020-01-06 01:51:06
问题 How to run database scripts(MySql db scripts) in c#. Thanks, sirni. 回答1: Fork a child process and execute the mysql command-line client, using the script as input. It's tempting to try to read the script as a file and execute the SQL commands within it one by one, but there are numerous statements in an SQL script that can't be executed that way. So you'd have to duplicate the code of the mysql client anyway in order to run an SQL script. Do yourself a favor and use the program that is

batch script to extract lines between two specified lines

别说谁变了你拦得住时间么 提交于 2020-01-05 19:44:50
问题 I have a text file and would like to extract all the lines between two specified lines using windows batch scripting. Line1: !FILE_FORMAT=ADS Line2: !VERSION=1.0 . . LineX: 'Parent|Child|IsPrimary| * *** (the line starts with ' and is long) . . LineY: !PropertyArray=Cost Center (The lines starts with !) . . LineZ. I want to extract all the lines between LineX and LineY and output it to another file. The below code finds the starting line correctly. But it just deletes the line(Line Y) where I

PBS programming

廉价感情. 提交于 2020-01-05 14:06:44
问题 some short and probably stupid questions about PBS: 1- I submit jobs using qsub job_file is it possible to submit a (sub)job inside a job file? 2- I have the following script: qsub job_a qsub job_b For launching job_b, it would be great to have before the results of job_a finished. Is it possible to put some kind of barrier or some otehr workaround so job_b is not launched until job_a finished? Thanks 回答1: Answer to the first question: Typically you're only allowed to submit jobs from the