command

Execute command and compare it in a if statement

你说的曾经没有我的故事 提交于 2021-02-08 10:35:12
问题 I am using bash scripting to check whether two specific directories are containing some specific number of files. lets assume 20. Is it possible to check it in a line inside a if statement? #!/bin/bash if [ [ls /path/to/dir1 | wc -l ] != 20 || [ ls /path/to/dir2 | wc -l ] != 50 ]; then echo "do this!" elif echo "do that!" fi 回答1: The syntax is incorrect: if [[ $(ls /path/to/dir1 | wc -l) != 20 || $(ls /path/to/dir2 | wc -l) != 50 ]] then echo "do this!" else echo "do that!" fi (I move the

Powershell: Piping output of pracl command to array

本小妞迷上赌 提交于 2021-02-08 09:29:25
问题 pracl is a sysinternal command that can be used to list the ACLs of a directory. I have a list of shares and I want to create a csv file such that for each ACL entry, I want the share path in one column and share permission in the next. I was trying to do that by using the following code $inputfile = "share.txt" $outputFile = "out.csv" foreach( $path in Get-Content $inputfile) { $results=.\pracl.exe $path { foreach ($result in $results) {write-host $path,$line} } $objResult = [pscustomobject]

How not to quote argument in subprocess?

你。 提交于 2021-02-08 06:19:59
问题 I'm trying to call an ImageMagick command from Python 2.7 using subprocess.call. My problem is that the argument parser in subprocess puts a double quotation mark around every argument, and ImageMagick seems to have a problem with quotes around non-file arguments. What I'd like is something like this "imagemagick.exe" "im1.png" "im2.png" -alpha off ( ... ) -composite "im3.png" So far I couldn't find a way to do it with subprocess, other than manually constructing the string with ugly + " " +

How not to quote argument in subprocess?

自古美人都是妖i 提交于 2021-02-08 06:19:16
问题 I'm trying to call an ImageMagick command from Python 2.7 using subprocess.call. My problem is that the argument parser in subprocess puts a double quotation mark around every argument, and ImageMagick seems to have a problem with quotes around non-file arguments. What I'd like is something like this "imagemagick.exe" "im1.png" "im2.png" -alpha off ( ... ) -composite "im3.png" So far I couldn't find a way to do it with subprocess, other than manually constructing the string with ugly + " " +

What actually happens when ApplicationCommands.Close is executed

巧了我就是萌 提交于 2021-02-07 19:18:41
问题 I guess the question in the title is clear enough.What happens when i call ApplicationCommands.Close.Execute(null,null) from my viewmodel class. I have a modeldialog which shows a usercontrol.I have a commandbinding to a button in the usercontrol which is executed in the viewmodel.I want to close the dialog after the command is executed.It can be done by using the above command to the end of the executed event. But i am wondering if this is the right approach.Will this cause any undesired

What actually happens when ApplicationCommands.Close is executed

浪尽此生 提交于 2021-02-07 19:18:31
问题 I guess the question in the title is clear enough.What happens when i call ApplicationCommands.Close.Execute(null,null) from my viewmodel class. I have a modeldialog which shows a usercontrol.I have a commandbinding to a button in the usercontrol which is executed in the viewmodel.I want to close the dialog after the command is executed.It can be done by using the above command to the end of the executed event. But i am wondering if this is the right approach.Will this cause any undesired

What actually happens when ApplicationCommands.Close is executed

杀马特。学长 韩版系。学妹 提交于 2021-02-07 19:18:02
问题 I guess the question in the title is clear enough.What happens when i call ApplicationCommands.Close.Execute(null,null) from my viewmodel class. I have a modeldialog which shows a usercontrol.I have a commandbinding to a button in the usercontrol which is executed in the viewmodel.I want to close the dialog after the command is executed.It can be done by using the above command to the end of the executed event. But i am wondering if this is the right approach.Will this cause any undesired

Custom Context Menu option for duplicating selected file not working as expected

≯℡__Kan透↙ 提交于 2021-02-07 10:49:50
问题 I am trying to create a custom Context Menu option for duplicating the selected file and appending date and time string to the copied file's name. Below is the command I have set in registry, in the HKCU > Softwares > Classes > * > Shell > Duplicate This File > Command: cmd /s /d /c @echo off & setlocal EnableExtensions EnableDelayedExpansion & set TIME=%TIME: =0% & set DateTimeFn=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%_!TIME:~0,2!-!TIME:~3,2!-!TIME:~6,2! & copy /y %1 %1_!DateTimeFn! & pause >

C#: get external shell command result line by line

戏子无情 提交于 2021-02-07 03:34:34
问题 I am writing a C# winform application that starts a second process to execute shell commands like "dir" and "ping". I redirect the second process's output so my app can receive the command result. It roughly works fine. The only problem is my winform app receives the command line output as a whole instead of line by line. For example, it has to wait for the external "ping" command to finish (which takes many seconds or longer) and then receives the whole output (many lines) at once. What I

C#: get external shell command result line by line

北慕城南 提交于 2021-02-07 03:31:36
问题 I am writing a C# winform application that starts a second process to execute shell commands like "dir" and "ping". I redirect the second process's output so my app can receive the command result. It roughly works fine. The only problem is my winform app receives the command line output as a whole instead of line by line. For example, it has to wait for the external "ping" command to finish (which takes many seconds or longer) and then receives the whole output (many lines) at once. What I