scripting

Add/remove xml tags using a bash script

老子叫甜甜 提交于 2019-12-17 22:23:49
问题 I have an xml file that I want to configure using a bash script. For example if I had this xml: <a> <b> <bb> <yyy> Bla </yyy> </bb> </b> <c> <cc> Something </cc> </c> <d> bla </d> </a> (confidential info removed) I would like to write a bash script that will remove section <b> (or comment it) but keep the rest of the xml intact. I am pretty new the the whole scripting thing. I was wondering if anyone could give me a hint as to what I should look into. I was thinking that sed could be used

Prevent bash from adding single quotes to variable output

爷,独闯天下 提交于 2019-12-17 20:51:07
问题 Problem: I'm writing a script that performs several HTTP requests with curl and I want to add the headers to a variable, CURL_HEADERS , so that I don't have to type them out constantly. When I echo the CURL_HEADERS variable in the curl command, single quotations appear where I don't want them. How can I prevent this? (The code below is simplified for the sake of clarity) Code #!/usr/bin/env bash AUTH_KEY='1234' set -x CURL_HEADERS='-H "Authorization: Basic '${AUTH_KEY}'" -H "Content-Type:

Python Login Script; Usernames and Passwords in a separate file

人走茶凉 提交于 2019-12-17 20:42:55
问题 I'm looking for assistance to get my Python script to imitate a log-in feature while the credentials are stored in a separate file. I got it to work from hard-coded Username and Password, and it also reads in a file, but I'm having some difficulty finding out how to link the two together. Any assistance is appreciated. The Python script is as follows: print "Login Script" import getpass CorrectUsername = "Test" CorrectPassword = "TestPW" loop = 'true' while (loop == 'true'): username = raw

Reading a CSV file using VBScript

旧时模样 提交于 2019-12-17 20:29:42
问题 I have a file with 4 fields. A,B,C,D I want to only extract the 4th Field and change it to "E" Is there anyway to accomplish this? 回答1: Assuming that the values don't contain commas, read in the file using FileSystemObject (FSO), then Split each line on commas. Change the resulting array of 4 values as needed, then join it together as a comma separated string again. When you've done all the changes, write the data back out to a file using FSO. So something like: Set outputFile = fso

Accessing shell script arguments by index

那年仲夏 提交于 2019-12-17 19:58:09
问题 I'm sure this is a no-brainer when you're into shell programming. Unfortunately I'm not and I'm having a pretty hard time ... I need to verify arguments passed to a shell script. I also want to store all parameters passed in an array as I need further separation later. I have an argument "-o" which must be followed by either 0 or 1. Thus, I want to check if the following argument is valid. Here's what I tried: # Loop over all arguments for i in "$@" do # Check if there is a "-" as first

How to run a powershell script with white spaces in path from command line?

浪子不回头ぞ 提交于 2019-12-17 19:22:43
问题 So I've tried a bunch of different ways to run a powershell script from the command line and every single one returns an error. Here is this path: C:\Users\test\Documents\test\line space\PS Script\test.ps1 I've tried these: powershell -File '"C:\Users\test\Documents\test\line space\PS Script\test.ps1"' powershell "& ""C:\Users\test\Documents\test\line space\PS Script\test.ps1""" Powershell "& 'C:\Users\test\Documents\test\line space\PS Script\test.ps1'" Powershell -File 'C:\Users\test

Execute a JavaScript function in a C# application

Deadly 提交于 2019-12-17 18:59:48
问题 Without using a WebBrowser control, how could I execute a JavaScript function, that is decoupled from any browser DOM dependencies, in a C# application? I am investigating implementing validation rules only once, for both server and client validation. See this question for reference if you like. Are there any JS interpretor libraries I could use? Addendum: My goal here is to automatically deploy and invoke exactly the same validation logic on client and server, without communication between

Replace delimited block of text in file with the contents of another file

[亡魂溺海] 提交于 2019-12-17 18:54:12
问题 I need to write a simple script to replace a block of text in a configuration file with the contents of another file. Let's assume with have the following simplified files: server.xml <?xml version='1.0' encoding='UTF-8'?> <Server port="8005" shutdown="SHUTDOWN"> <Service name="Catalina"> <Connector port="80" protocol="HTTP/1.1"/> <Engine name="Catalina" defaultHost="localhost"> <!-- BEGIN realm --> <sometags/> <sometags/> <!-- END realm --> <Host name="localhost" appBase="webapps"/> </Engine

java scripting API - how to stop the evaluation

空扰寡人 提交于 2019-12-17 18:32:03
问题 i have writen a servlet that recives a java script code and process it and returns the answer. for that i have used the java scripting API in the code below if script = "print('Hello, World')"; the code will end properly print "hello world". but if script = "while(true);" the script will loop endlessly. import javax.script.*; public class EvalScript { public static void main(String[] args) throws Exception { // create a script engine manager ScriptEngineManager factory = new

C#/.NET scripting library

送分小仙女□ 提交于 2019-12-17 18:29:57
问题 I want to enhance an application with scripting support like many other applications have, e.g. MS Office using VBA or UltraEdit using JavaScript. Which libraries do exist for C#/.NET (and which language(s) do they support)? 回答1: IronPython is a dynamic .NET scripting language. IronPython is an implementation of the Python programming language running under .NET and Silverlight. It supports an interactive console with fully dynamic compilation. It's well integrated with the rest of the .NET