command

Bash conditional based on exit code of command

二次信任 提交于 2021-01-29 10:18:21
问题 In Bash, I would like an if statement which is based of the exit code of running a command. For example: #!/bin/bash if [ ./success.sh ]; then echo "First: success!" else echo "First: failure!" fi if [ ./failure.sh ]; then echo "Second: success!" else echo "Second: failure!" fi success.sh #!/bin/bash exit 0 failure.sh #!/bin/bash exit 1 This should print out: First: success! Second: failure! How would I achieve this? Thanks! 回答1: Just remove the brackets: #!/bin/bash if ./success.sh; then

How can I enable/disable command in Visual Studio 2017 VSIX C# project

◇◆丶佛笑我妖孽 提交于 2021-01-29 09:00:35
问题 I'm developing an extension for Visual Studio 2017 using a C# VSIX project. I need to create a variable number of commands based on settings in a .ini file. I thought to create a maximum number of commands (because in a VSIX project every command needs a new .cs file), and enable only the commands written in the .ini file. Unfortunately I don't know how to disable a command. I need to enable the commands when a boolean becomes true. I've seen that I need to use the OleMenuCommand class, but I

CS0201 error in ICommand impmentation for WPF application

混江龙づ霸主 提交于 2021-01-29 08:27:15
问题 I develop a WPF application, obviously, I use MVVM pattern. Without an external library (MvvmCross, MvvmLight, ...) And I've tried to implement ICommand : Option 1 public class Command : ICommand { private readonly Func<bool> _canExecute; private readonly Action _action; public Command1(Action action, Func<bool> canExecute) { _action = action; _canExecute = canExecute; } public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager

Set a return value as variable in window batch

僤鯓⒐⒋嵵緔 提交于 2021-01-29 08:14:08
问题 How can I use if else statement to echo if value more than 1? @echo off setlocal set "sql=c:\xampp\mysql\bin\mysql.exe" for /f "usebackq" %%a in (`%sql% -u root -ss -e "select COUNT(*) FROM mytable" mydatabase`) do set TESTVAR=%%a if %TESTVAR% GEQ 1 (echo Database has already existed.) else echo import pause 回答1: Kind of like this: @echo off setlocal set "sql=c:\xampp\mysql\bin\mysql.exe" for /f "usebackq" %%a in (`%sql% -u root -ss -e "select COUNT^(*^) FROM browser" form_generator`) do set

Start Outlook Command Line Switches Parameters And Launch Macro

隐身守侯 提交于 2021-01-29 04:27:42
问题 I'd like to open outlook via command with parameters and launch macro once is opened... this code open outlook with parameters outlook.exe /c ipm.note /m "m@m.m&subject=abc&body=123" /a "f:\attach.txt" if I add code to launch a macro, outlook won't open and give me an error... what's wrong in this code ? outlook.exe /c ipm.note /m "m@m.m,&subject=abc&body=123" /a "f:\attach.txt" /autorun mymacro 回答1: You can't run a macro using a command-line switch. The only relevant command is /altvba, but

Creating process with arguments in Swift?

醉酒当歌 提交于 2021-01-28 20:49:37
问题 Problem with doing process in Swift 3, It's not working, I click and nothing is happening. let open = Process() open.launchPath = "/usr/bin/openssl" open.arguments = ["openssl enc -aes-256-cbc -d -in \"" + existing.stringValue + "\" -out \"" + new.stringValue + "/" + name.stringValue + "\""] open.launch() open.waitUntilExit() How do I create a process with arguments in Swift? 回答1: With this function, you can pass the arguments as a string. func shell(at: String, _ args: String) { let task =

Sending command via Slack API

对着背影说爱祢 提交于 2021-01-27 22:15:43
问题 Is there a way to programmatically send a command to Slack via the API? I'm successfully posting a message using var postingResponse = client.UploadValues("https://slack.com/api/chat.postMessage", "POST", new NameValueCollection() { {"token","<token>"}, {"channel","<ID>"}, {"text", "/mycommand hello" }, {"username","<username>" }, {"link_names", "true" }, {"parse", "full" } }); This works well but the /mycommand hello is just printed as text instead of executing as a command. I tried adding a

Sending command via Slack API

試著忘記壹切 提交于 2021-01-27 20:27:37
问题 Is there a way to programmatically send a command to Slack via the API? I'm successfully posting a message using var postingResponse = client.UploadValues("https://slack.com/api/chat.postMessage", "POST", new NameValueCollection() { {"token","<token>"}, {"channel","<ID>"}, {"text", "/mycommand hello" }, {"username","<username>" }, {"link_names", "true" }, {"parse", "full" } }); This works well but the /mycommand hello is just printed as text instead of executing as a command. I tried adding a

BASH: Filter list of files by return value of another command

无人久伴 提交于 2021-01-27 20:04:31
问题 I have series of directories with (mostly) video files in them, say test1 1.mpg 2.avi 3.mpeg junk.sh test2 123.avi 432.avi 432.srt test3 asdf.mpg qwerty.mpeg I create a variable ( video_dir ) with the directory names (based on other parameters) and use that with find to generate the basic list. I then filter based on another variable ( video_type ) for file types (because there is sometimes non-video files in the dirs) piping it through egrep . Then I shuffle the list around and save it out

Redis commands queue size

核能气质少年 提交于 2021-01-27 04:36:56
问题 How to log/measure the size of Redis command's queue. The Redis is single-threaded, so it runs commands sequentially, as I guess there is command queue there, where the incoming commands are stored, and executed one by one. The SLOWLOG command only shows the execution time, so the question is, is there a way to get how long the command was in queue before starting of execution. 回答1: AFAIK, there is no command queue in Redis. The event loop is notified when there is something to read on a