scripting

Maximum element and its indices from an array in shell script

纵然是瞬间 提交于 2020-01-02 07:15:12
问题 How can I find the maximum element and its index from an array in shell script. I have an array a = [-2.2116565098 -2.1238242060 -2.1747941240 -2.3201010162 -2.3677779871 -1.8126464132 -2.1247209755 -2.1190930712 -2.3242384636 -2.1081702064]; Now, I want to find the maximum as well as its index in bash script. Is there a shortcut like in Matlab we have [C, I] = max(a); Also, also how can we have multi-dimensional array and get the index and value of minimum and maximum element. 回答1: $ x='-2

can an RPM spec file “include” other files?

你离开我真会死。 提交于 2020-01-02 01:30:30
问题 Is there a kind of "include" directive in RPM spec? I couldn't find an answer by googling. Motivation : I have a RPM spec template which the build process modifies with the version, revision and other build-specific data. This is done by sed currently. I think it would be cleaner if the spec would #include a build-specific definitions file, which would be generated by the build process, so I don't need to search and replace in the spec. If there is no include , is there an idiomatic way to do

How do you glue Lua to C++ code?

有些话、适合烂在心里 提交于 2020-01-02 01:12:13
问题 Do you use Luabind, toLua++, or some other library (if so, which one) or none at all? For each approach, what are the pro's and con's? 回答1: I can't really agree with the 'roll your own' vote, binding basic types and static C functions to Lua is trivial, yes, but the picture changes the moment you start dealing with tables and metatables; things go trickier very quickly. LuaBind seems to do the job, but I have a philosophical issue with it. For me it seems like if your types are already

Strange question about windows batch file

痴心易碎 提交于 2020-01-01 17:57:17
问题 I got 1.txt and 2.txt in my working directory. I use the following batch to list all the files. The batch is this: @echo off for /f "tokens=*" %%a in ('dir *.txt /b') do ( echo --------------- set file_variable=%%a echo file_variable=%file_variable% echo filename=%%a ) The result is below: --------------- file_variable=2.txt <---------------why it is not 1.txt here?? filename=1.txt --------------- file_variable=2.txt filename=2.txt Thanks. 回答1: You need to put: @setlocal enableextensions

Best/Easiest/Quickest way to get relative path between two files?

做~自己de王妃 提交于 2020-01-01 16:12:29
问题 I'm in the midst of some refactoring some C# code and part of this is to redo some references, because we're redoing the folder structure entirely. What I'd like to do is just go into the .csproj or .sln file and modify the paths. However some of the references have paths like "../../../../../../ThirdParty/SomeMicrosoftLibrary/bin/Debug/SomeMicrosoftLibrary.dll And since we've moved everything around I need to find the new relative path. But I absolutely hate trying to do this (figure out how

Best/Easiest/Quickest way to get relative path between two files?

北慕城南 提交于 2020-01-01 16:12:09
问题 I'm in the midst of some refactoring some C# code and part of this is to redo some references, because we're redoing the folder structure entirely. What I'd like to do is just go into the .csproj or .sln file and modify the paths. However some of the references have paths like "../../../../../../ThirdParty/SomeMicrosoftLibrary/bin/Debug/SomeMicrosoftLibrary.dll And since we've moved everything around I need to find the new relative path. But I absolutely hate trying to do this (figure out how

Can I instantiate beanshell class sourced from another Beanshell script?

久未见 提交于 2020-01-01 15:34:28
问题 I would like to run class imported from different beanshell file. But I've no idea how instantiate class from main beanshell file. Is this possible? Class which I import: class HelloW { public void run(){ print("Hello World"); } } Main beanshell file which should run and instantiate class: Interpreter i = new Interpreter(); i.source("HelloW.bsh"); 回答1: The BeanShell documentation is pretty good in this area, so you should read through that first. In your case there are few issues. That said,

Can I instantiate beanshell class sourced from another Beanshell script?

穿精又带淫゛_ 提交于 2020-01-01 15:33:14
问题 I would like to run class imported from different beanshell file. But I've no idea how instantiate class from main beanshell file. Is this possible? Class which I import: class HelloW { public void run(){ print("Hello World"); } } Main beanshell file which should run and instantiate class: Interpreter i = new Interpreter(); i.source("HelloW.bsh"); 回答1: The BeanShell documentation is pretty good in this area, so you should read through that first. In your case there are few issues. That said,

How to pass argument to PuTTY commands file

好久不见. 提交于 2020-01-01 14:09:55
问题 I have a batch file that starts PuTTY and executes commands listed in a text file. I want to be able to pass in parameters to the text file that has my commands to be run on the remote server. This is what I currently have - start C:\Users\putty.exe -load "server" -l userID -pw Password -m commands.txt Is there a way to pass for example a version number as an argument to the commands.txt file? 回答1: You have to generate the commands.txt on the fly: set PARAMETER=parameter echo ./myscript.sh

How to pass argument to PuTTY commands file

被刻印的时光 ゝ 提交于 2020-01-01 14:09:04
问题 I have a batch file that starts PuTTY and executes commands listed in a text file. I want to be able to pass in parameters to the text file that has my commands to be run on the remote server. This is what I currently have - start C:\Users\putty.exe -load "server" -l userID -pw Password -m commands.txt Is there a way to pass for example a version number as an argument to the commands.txt file? 回答1: You have to generate the commands.txt on the fly: set PARAMETER=parameter echo ./myscript.sh