command-line

Execute the result of a sql select in MySql

元气小坏坏 提交于 2021-01-27 21:30:40
问题 I am trying to get MySql to execute the result of the below statement as further sql statements. I believe in oracle sqlplus this is achieved using the spool function. How is this achieved in Mysql ? select concat('OPTIMIZE TABLE `', ist.TABLE_SCHEMA,'`.', ist.TABLE_NAME, ';') FROM INFORMATION_SCHEMA.TABLES ist where table_schema = 'my_schema'; 回答1: You have to use prepared statements. SET @s:=''; SELECT @s:=concat(@s, 'OPTIMIZE TABLE `', ist.TABLE_SCHEMA,'`.', ist.TABLE_NAME, ';') FROM

How to tell bash not to issue warnings “cannot set terminal process group” and “no job control in this shell” when it can't assert job control?

情到浓时终转凉″ 提交于 2021-01-27 18:23:12
问题 To create a new interactive bash shell I call bash -i . Due to issues with my environment, bash cannot assert job control (I'm using cygwin bash in GNU emacs) and issues warnings ("cannot set terminal process group" and "no job control in this shell"). - I have to live with the disabled job control in my environment, but I would like to get rid of the warning: How can I tell bash not to assert job control and not to issue these warnings? I obviously still want the shell as an interactive one.

Argparse: How to disallow some options in the presence of others - Python

倾然丶 夕夏残阳落幕 提交于 2021-01-27 17:54:39
问题 I have the following utility: import argparse parser = argparse.ArgumentParser(description='Do some action.') parser.add_argument('--foo', '--fo', type=int, default=-1, help='do something foo') parser.add_argument('--bar', '--br', type=int, default=-1, help='do something bar') parser.add_argument('--baz', '--bz', type=int, default=-1, help='do something baz') parser.add_argument('--bat', '--bt', type=int, default=-1, help='do something bat') However, if the --foo option is used, the --bat

How can I do bash arithmetic with variables that are numbers with leading zeroes? [duplicate]

杀马特。学长 韩版系。学妹 提交于 2021-01-27 07:02:55
问题 This question already has answers here : How can I increment a number in a while-loop while preserving leading zeroes (BASH < V4) (3 answers) incrementing a number in bash with leading 0 (8 answers) Closed 2 years ago . I have the following code in a bash script, where "values" is a variable of newline separated numbers, some of which have leading 0's , and I am trying to iterate through each value in values and add each value to the variable "sum". sum=0 while read line; do sum=$(( sum +

How can I do bash arithmetic with variables that are numbers with leading zeroes? [duplicate]

对着背影说爱祢 提交于 2021-01-27 07:01:21
问题 This question already has answers here : How can I increment a number in a while-loop while preserving leading zeroes (BASH < V4) (3 answers) incrementing a number in bash with leading 0 (8 answers) Closed 2 years ago . I have the following code in a bash script, where "values" is a variable of newline separated numbers, some of which have leading 0's , and I am trying to iterate through each value in values and add each value to the variable "sum". sum=0 while read line; do sum=$(( sum +

How do you pipe scripts into NodeJs from command line?

你说的曾经没有我的故事 提交于 2021-01-27 04:43:37
问题 From command line, I'd like to take a script from my paste board (FYI: pbpaste is an OSX feature) and pipe it into the Node's repl command line tool. For example: pbpaste | node -e This does not evaluate the contents in my clipboard. How do I get the runtime to do this? 回答1: The -e option is for running JS passed as an argument. To run JS from stdin, you can simply pipe to node directly. pbpaste | node 回答2: This seems to do the trick: node -e "$(pbpaste)" 来源: https://stackoverflow.com

Stop running PHP server, command line

时光毁灭记忆、已成空白 提交于 2021-01-26 03:53:15
问题 So I've done php -S localhost:8000 , but I don't need it anymore, I need my 8000 localhost back. How to stop the php server? 回答1: PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011 Listening on localhost:8000 Document root is /home/me/public_html Press Ctrl-C to quit. If you don't have that terminal open, you have to find the PID of the process and kill that. To find the PID and kill the process, here is a nice explanation. 回答2: killall -9 php That's how I would do it! 来源: https

Stop running PHP server, command line

谁都会走 提交于 2021-01-26 03:48:51
问题 So I've done php -S localhost:8000 , but I don't need it anymore, I need my 8000 localhost back. How to stop the php server? 回答1: PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011 Listening on localhost:8000 Document root is /home/me/public_html Press Ctrl-C to quit. If you don't have that terminal open, you have to find the PID of the process and kill that. To find the PID and kill the process, here is a nice explanation. 回答2: killall -9 php That's how I would do it! 来源: https

Remote Desktop / RDP credentials check from command line (no GUI)

帅比萌擦擦* 提交于 2021-01-24 11:32:51
问题 We're currently writing a tool aimed at checking the validity of credentials over various applications (http, ssh, smb, rdp). No problem for the 3 former. But for RDP, I couldn't find a single way of doing this easily. The tool is embedded within a web app hosted on a linux box, therefore there is no X Server available. The only tool I have successfully used to validate RDP credentials from the command line is THC-Hydra, by supplying a single username and password, it works correctly for

Remote Desktop / RDP credentials check from command line (no GUI)

試著忘記壹切 提交于 2021-01-24 11:32:26
问题 We're currently writing a tool aimed at checking the validity of credentials over various applications (http, ssh, smb, rdp). No problem for the 3 former. But for RDP, I couldn't find a single way of doing this easily. The tool is embedded within a web app hosted on a linux box, therefore there is no X Server available. The only tool I have successfully used to validate RDP credentials from the command line is THC-Hydra, by supplying a single username and password, it works correctly for