command

Regular Expression Match to Extract Command

痴心易碎 提交于 2019-12-12 18:39:32
问题 String: Z123xy;Z123od33;Z123od343;Z251od541; Regex: Z.*?od.*?; Required Output: [Z123od33; Z123od343; Z251od541;] But Current Output : [Z123xy;Z123od33; Z123od343; Z251od541;] I know why its happening that way but don't know how to solve this. Any one could help please 回答1: You could go for Z[^;]*?od[^;]*?; # require a Z # anything not a ; lazily # od # anything not a ; lazily again # followed by a ; See a demo on regex101.com or split on the ; and analyze the parts later separately. 来源:

Laravel Test | Mock object in Laravel Artisan Command

独自空忆成欢 提交于 2019-12-12 15:17:14
问题 I want to test my Laravel Artisan command. So I need to mock an object and stubs this mocked object methods. In my test, I cannot use the real SFTP environment. This is the handle() of my command: public function handle() { $sftp = new SFTP('my.sftpenv.com'); $sftp->login('foo', 'bar'); } I want to mock the SFTP in my test: $sftp = $this->createMock(SFTP::class); $sftp->expects($this->any())->method('login')->with('foo', 'bar'); $this->artisan('import:foo'); Running the test results in a

Linux command to send binary file to serial port with HW flow control?

独自空忆成欢 提交于 2019-12-12 14:43:16
问题 I need to send binary file to rs232 device (printer) which not always can accept data and so it has BUSY output signal, which i connect to CTS pin. I try to use it with minicom , and hardware flow control works just fine. But i can't send raw file using minicom, it works wrong ant i think minicom not loves zeroes in file. At other hand, i try to use cat file > /dev/ttyS5 , along with stty -F /dev/ttyS5 clocal or stty -F /dev/ttyS5 crtscts . None of this work: HW control not work at all, data

How can the Git command be executed on Windows through Gradle?

杀马特。学长 韩版系。学妹 提交于 2019-12-12 13:24:49
问题 So I have the following code snippet: def getVersion = { -> def stdout = new ByteArrayOutputStream() exec { commandLine 'git', 'describe', '--tags' standardOutput = stdout } return stdout.toString().trim() } and whenever I call getVersion() , I get the following error: * What went wrong: A problem occurred evaluating root project 'ForgeWorkspace'. > Process 'command 'git'' finished with non-zero exit value 128 * Try: Run with --stacktrace option to get the stack trace. Run with --info or -

Vim: How to reformat a set of lines into a single line (if the line is a single sentence)?

跟風遠走 提交于 2019-12-12 13:10:03
问题 Not a dup of In Vim, what is the simplest way to join all lines in a file into a single line?, as I specifically mean to use the gq reformatting functionality. I used to write latex in vim using 80 character textwidth . However, I've now switched to an infinite textwidth , so my lines go on forever. Vim's reformatting (gqap for example), combines a few lines into a paragraph, wrapping them at 80 characters. I'd like it to instead combine them into a single line. ie Without a \clang{goto}

How to check if command is available or existant?

≯℡__Kan透↙ 提交于 2019-12-12 12:29:34
问题 I am developing a console application in C on linux. Now an optional part of it (its not a requirement) is dependant on a command/binary being available. If I check with system() I'm getting sh: command not found as unwanted output and it detects it as existent. So how would I check if the command is there? Not a duplicate of Check if a program exists from a Bash script since I'm working with C, not BASH. 回答1: To answer your question about how to discover if the command exists with your code.

CommandBinding in Window doesn't catch execution of command from ContextMenu

你离开我真会死。 提交于 2019-12-12 12:11:17
问题 A quite simple and straightforward example. I have a window. It has CommandBindings set to catch a RoutedUICommand execution. <Window ... > <Window.CommandBinding> <CommandBinding Command="{x:Static local:Commands.Command1}" Executed="OnCommand1Executed" CanExecute="OnCanCommand1Execute" /> </Window.CommandBinding> </Window> There's a UserControl hosted in the window, inside of which a ContextMenu is declared. A ContextMenu item has the Command property assigned to the same RoutedUICommand.

Taking the results of a bash command and using it in python

末鹿安然 提交于 2019-12-12 12:08:05
问题 I am trying to write a code in python that will take some information from top and put it into a file. I want to just write the name of the application and generate the file. The problem i am having is that i can't get the output of the pidof command so i can use it in python. My code looks like this : import os a = input('Name of the application') val=os.system('pidof ' + str(a)) os.system('top -d 30 | grep' + str(val) + '> test.txt') os.system('awk '{print $10, $11}' test.txt > test2.txt')

Bind any key pressed to command in VM WPF

人走茶凉 提交于 2019-12-12 10:37:24
问题 I'm trying to bind any keyboard key pressed to a command in the ViewModel . I know that I can bind a specific key, using: <Window.InputBindings> <KeyBinding Command="{Binding ChangeIdCommand}" Key="B"/> </Window.InputBindings> Can I bind all key presses to ChangeIdCommand without having to type them all manually? 回答1: Try this after your window definition: <Window x:Class="wpfApplication.MainWindow" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" ...> <i:Interaction

How to log the time taken for a unix command?

て烟熏妆下的殇ゞ 提交于 2019-12-12 10:36:40
问题 I know my script is going to take more than 10 hours to run. Is there a way to log the time it starts and the time it ends ? Does the time command just time the process or do I get the output of the process that I'm timing ? 回答1: Use the time command (details): time your_prog If time does not fit for you, I would try to log the output of date (details) before and after the execution of your program, e.g. date > log.txt; your_prog; date >> log.txt Finally, you can also add some formatting (