scripting

How to output awk result to file

旧城冷巷雨未停 提交于 2019-12-23 13:21:05
问题 I am trying to output 'awk' result to file in my script, with no success. Using '>' does not work, why? for a in $(find $OUPUT_DIR/ -maxdepth 1 -mindepth 1 -type d -printf "%P\n") do echo $a is a directory awk -F, '{ if ($10 == '"$a"') print $0 }' $OUPUT_DIR/CDRNOutput_${CDR_DATE}.csv > $OUPUT_DIR/$a/CDR-${CDR_DATE}.csv done 回答1: Output redirection is generally a feature of the shell you're working with and, given how much use it gets, I'd be pretty amazed if you'd found a bug in it :-) Are

Get the name of the directory where a script is executed

人盡茶涼 提交于 2019-12-23 12:31:10
问题 I have some script, that uses files in directories around it. It uses dirname $0 command. It should work from any directory where I run this script, but when I run a symbolic link that points to that script I get the path of symbolic link. So I get the output of dirname rather than the path of the script itself. Any one know a way to get the path of where the script is run? 回答1: Get the real path to your script if [ -L $0 ] ; then ME=$(readlink $0) else ME=$0 fi DIR=$(dirname $ME) 回答2: if you

Script to export to excel

非 Y 不嫁゛ 提交于 2019-12-23 12:27:27
问题 I Have below script:-- looking for help to convert the output to excel format $servers = get-content “c:\list.txt” foreach ($server in $servers) { $server $command = “quser /server:” + $server invoke-expression $command } when executed getting in below format the output. server1 USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME Vdw231 ica-tcp#8 7 Active . 11/5/2012 10:40 AM Vdw232 ica-tcp#60 16 Active 16:18 11/5/2012 2:22 PM Vdw233 ica-tcp#71 3 Active . 11/6/2012 6:10 AM Vdw234 ica-tcp#72 1

Reading the list of References from All csproj project of solution sln (programmatically)

╄→гoц情女王★ 提交于 2019-12-23 10:55:06
问题 I have solution sln, that has many csproj projects. anyone know a way to programmatically read the list of References of all csproj projects in a VS2008 of sln file? 回答1: csproj files are just XML files. You can use XDocument from the .NET framework for this. I've done it for VS2010, but in VS2008 the tags are almost the same. Example for VS2010, you have to verify the tags and namespace: XElement projectNode = XElement.Load(fileName); XNamespace ns = "http://schemas.microsoft.com/developer

Hosting .fsx scripts inside larger applications

筅森魡賤 提交于 2019-12-23 10:49:34
问题 I want to expose my F# libraries as a scriptable tool for data manipulation. Optimally, I want this scripting facility to not require a full F# install with fsi and so on. Is there a way to link into the FSI libraries to execute scripts from F# code? My google-fu is failing me on this one, and the F# sources for fsi are a bit tangled. 回答1: No, there's no hosting API for F# interactive sessions. fsi.exe itself is factored into a lightweight client process that handles the interaction, and a

Make log reading efficient

蓝咒 提交于 2019-12-23 09:55:54
问题 I have a perl script that is used to monitor databases and I'm trying to write it as a powershell script. In the perl script there is a function that reads through the errorlog and filters out what it is that matters and returns it back. It also saves the current position of the log file so that the next time it has to read the log it can start where it left of instead of reading the whole log again. This is done by using the tell function. I have an idea to use the Get-Content cmdlet, and

How to make expect command in expect program script to wait for exact string matching

随声附和 提交于 2019-12-23 09:46:59
问题 I want to know how to make expect command in expect script to wait for exact string to be matched before proceeding to next line in the script. Bourne shell (sh) script: #!/bin/sh #!/usr/bin/expect spawn ssh -Y localuser@lbblr-tirumala expect -exact "localuser@lbblr-tirumala's password: " # replace password with ur own passwd send "geomax45\r" # replace the prompt with ur own prompt expect "localuser@lbblr-tirumala:~$ " # run application send "./sample\r" expect "*Menu*\r 1. print hello world

How do I enable C# scripting in VS 2015?

做~自己de王妃 提交于 2019-12-23 08:50:03
问题 How do I configure VS 2015 to enable Roslyn's C# scripting capabilities? I've tried installing various Nuget packages, including both the 1.0 and 1.1.0-beta1 versions of Microsoft.CodeAnalysis.CSharp, Microsoft.CodeAnalysis.Scripting.CSharp, etc., but I can't get any of the examples I've found online to work. I am getting "type not found" errors, i.e., var scriptEngine = new ScriptEngine(); ... fails because the type "ScriptEngine" is not found. Can someone provide as recipe that includes

Running the Script, made by generate script on different server gives error

痞子三分冷 提交于 2019-12-23 06:48:09
问题 the following is a script which was generated using generate script option. the wizard says that this can be used to copy, create db on different servers so its made for it, then why does this error occur.?? the error is Msg 5170, Level 16, State 1, Line 2 Cannot create file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SECOND\MSSQL\DATA\Script Me.mdf' because it already exists. Change the file path or the file name, and retry the operation. Msg 1802, Level 16, State 4, Line 2 and could

Running the Script, made by generate script on different server gives error

旧街凉风 提交于 2019-12-23 06:48:03
问题 the following is a script which was generated using generate script option. the wizard says that this can be used to copy, create db on different servers so its made for it, then why does this error occur.?? the error is Msg 5170, Level 16, State 1, Line 2 Cannot create file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SECOND\MSSQL\DATA\Script Me.mdf' because it already exists. Change the file path or the file name, and retry the operation. Msg 1802, Level 16, State 4, Line 2 and could