QuestionId
stringlengths
3
8
QuestionTitle
stringlengths
15
149
QuestionScore
int64
1
27.2k
QuestionCreatedUtc
stringdate
2008-08-01 18:33:08
2025-06-16 04:59:48
QuestionBodyHtml
stringlengths
40
28.2k
QuestionViewCount
int64
78
16.5M
QuestionOwnerUserId
float64
4
25.2M
QuestionLastActivityUtc
stringdate
2008-09-08 19:26:01
2026-01-24 22:40:25
AcceptedAnswerId
int64
266
79.7M
AnswerScore
int64
2
30.1k
AnswerCreatedUtc
stringdate
2008-08-01 23:40:28
2025-06-16 05:23:39
AnswerOwnerUserId
float64
1
29.5M
AnswerLastActivityUtc
stringdate
2008-08-01 23:40:28
2026-01-23 17:46:09
QuestionLink
stringlengths
31
36
AnswerLink
stringlengths
31
36
AnswerBodyHtml
stringlengths
35
33k
AnswerBodyPreview
stringlengths
35
400
AllTagIdsCsv
stringlengths
2
37
AllTagNamesCsv
stringlengths
2
106
MergedQuestion
stringlengths
74
28.4k
quality_filter
stringclasses
10 values
unique_id
int64
0
29k
tag_major_lang
stringclasses
10 values
MergedQuestion_md
stringlengths
60
28.1k
AnswerBodyHtml_md
stringlengths
14
29.2k
23421507
Get service status from remote server using powershell
12
2014-05-02 05:41:53
<p>How to get the service status for a remote computer that needs a user name and password to log in?</p> <p>I am trying to find a solution using the following code:</p> <p><code>$serviceStatus = get-service -ComputerName $machineName -Name $service</code></p> <p>The default syntax for the <code>get-service</code> c...
104,227
1,631,315
2020-07-08 16:54:34
23,421,592
14
2014-05-02 05:48:48
311,712
2014-05-02 06:08:52
https://stackoverflow.com/q/23421507
https://stackoverflow.com/a/23421592
<p>As far as I know, Get-Service <a href="http://connect.microsoft.com/PowerShell/feedback/details/567007/get-service-cmdlets-needs-a-credential-parameter" rel="noreferrer">doesn't accept a credential parameter</a>. However, you can do it through <a href="http://technet.microsoft.com/en-us/library/ee176860.aspx" rel="n...
<p>As far as I know, Get-Service <a href="http://connect.microsoft.com/PowerShell/feedback/details/567007/get-service-cmdlets-needs-a-credential-parameter" rel="noreferrer">doesn't accept a credential parameter</a>. However, you can do it through <a href="http://technet.microsoft.com/en-us/library/ee176860.aspx" rel="n...
526, 627, 18556
powershell, remote-server, service
<h1>Get service status from remote server using powershell</h1> <p>How to get the service status for a remote computer that needs a user name and password to log in?</p> <p>I am trying to find a solution using the following code:</p> <p><code>$serviceStatus = get-service -ComputerName $machineName -Name $service</cod...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,666
bash
# Get service status from remote server using powershell How to get the service status for a remote computer that needs a user name and password to log in? I am trying to find a solution using the following code: `$serviceStatus = get-service -ComputerName $machineName -Name $service` The default syntax for the `ge...
As far as I know, Get-Service [doesn't accept a credential parameter](http://connect.microsoft.com/PowerShell/feedback/details/567007/get-service-cmdlets-needs-a-credential-parameter). However, you can do it through [WMI](http://technet.microsoft.com/en-us/library/ee176860.aspx): ``` $cred = get-Credential -credential...
20177996
Ansible Playbook to run Shell commands
12
2013-11-24 18:09:45
<p>I recently dived into Ansible for one of my servers, and found it really interesting and time saving. I am running an Ubuntu dedicated server and have configured number of web applications written on Python and a few on PHP. For Python I am using uwsgi as the HTTP gateway. I have written shell scripts to start/resta...
41,399
1,554,460
2015-12-18 09:20:04
20,179,863
14
2013-11-24 19:28:54
467,722
2013-11-24 22:09:13
https://stackoverflow.com/q/20177996
https://stackoverflow.com/a/20179863
<p>You don't even need a playbook to do this :</p> <ul> <li>Restarting nginx : </li> </ul> <p><code>ansible your_host -m service -a 'name=nginx state=restarted'</code> </p> <p>(see <a href="http://www.ansibleworks.com/docs/modules.html#id343" rel="noreferrer">service module</a>)</p> <ul> <li>Kill a process by proce...
<p>You don't even need a playbook to do this :</p> <ul> <li>Restarting nginx : </li> </ul> <p><code>ansible your_host -m service -a 'name=nginx state=restarted'</code> </p> <p>(see <a href="http://www.ansibleworks.com/docs/modules.html#id343" rel="noreferrer">service module</a>)</p> <ul> <li>Kill a process by proce...
390, 6605, 58380, 86394
ansible, nginx, shell, uwsgi
<h1>Ansible Playbook to run Shell commands</h1> <p>I recently dived into Ansible for one of my servers, and found it really interesting and time saving. I am running an Ubuntu dedicated server and have configured number of web applications written on Python and a few on PHP. For Python I am using uwsgi as the HTTP gate...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,667
bash
# Ansible Playbook to run Shell commands I recently dived into Ansible for one of my servers, and found it really interesting and time saving. I am running an Ubuntu dedicated server and have configured number of web applications written on Python and a few on PHP. For Python I am using uwsgi as the HTTP gateway. I ha...
You don't even need a playbook to do this : - Restarting nginx : `ansible your_host -m service -a 'name=nginx state=restarted'` (see [service module](http://www.ansibleworks.com/docs/modules.html#id343)) - Kill a process by process id `ansible your_host -m command -a 'kill -TERM your_pid'` (adjust signal, and use...
19546241
EntityFramework 6.0 CreateDatabaseIfNotExists Code first to create database
12
2013-10-23 15:40:36
<p>What am I doing wrong. I have got a user DbContext setup and working when I originally created the Code-First with powershell it all worked fine. </p> <p>I implemented Database Initializer as expected on application start. </p> <pre><code>Database.SetInitializer&lt;UserDbContext&gt;(new CreateDatabaseIfNotExists&l...
37,984
685,754
2013-10-23 17:07:52
19,548,015
14
2013-10-23 17:07:52
685,754
2013-10-23 17:07:52
https://stackoverflow.com/q/19546241
https://stackoverflow.com/a/19548015
<p>Finally figured the solutions, not sure why or what. Changed my Database initializer to MigrateDatabaseToLatestVersion instead of CreateDatabaseIfNotExists worked. </p> <pre><code>Database.SetInitializer&lt;UserDbContext&gt;(new MigrateDatabaseToLatestVersion&lt;UserDbContext, Configuration&gt;()); </code></pre>
<p>Finally figured the solutions, not sure why or what. Changed my Database initializer to MigrateDatabaseToLatestVersion instead of CreateDatabaseIfNotExists worked. </p> <pre><code>Database.SetInitializer&lt;UserDbContext&gt;(new MigrateDatabaseToLatestVersion&lt;UserDbContext, Configuration&gt;()); </code></pre>
9, 526, 2535
c#, entity-framework, powershell
<h1>EntityFramework 6.0 CreateDatabaseIfNotExists Code first to create database</h1> <p>What am I doing wrong. I have got a user DbContext setup and working when I originally created the Code-First with powershell it all worked fine. </p> <p>I implemented Database Initializer as expected on application start. </p> <p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,668
bash
# EntityFramework 6.0 CreateDatabaseIfNotExists Code first to create database What am I doing wrong. I have got a user DbContext setup and working when I originally created the Code-First with powershell it all worked fine. I implemented Database Initializer as expected on application start. ``` Database.SetInitiali...
Finally figured the solutions, not sure why or what. Changed my Database initializer to MigrateDatabaseToLatestVersion instead of CreateDatabaseIfNotExists worked. ``` Database.SetInitializer<UserDbContext>(new MigrateDatabaseToLatestVersion<UserDbContext, Configuration>()); ```
18092343
Unmount my external hard drive in bash
12
2013-08-06 23:42:27
<p>So, this should apparently be really simple, but had trouble finding any good answers online.</p> <p>I have a mounted external usb hard drive.</p> <p>I would like to unmount it, using bash. (Essentially I'm just looking for the equivalent bash command for right clicking on my external hard drive in nautilus and se...
22,005
2,569,425
2019-05-30 03:47:29
18,092,395
14
2013-08-06 23:49:11
1,513,060
2017-02-20 23:07:19
https://stackoverflow.com/q/18092343
https://stackoverflow.com/a/18092395
<p>Searching for "Unmount Hard Drive Terminal" yields <a href="http://ubuntuforums.org/showthread.php?t=842698" rel="noreferrer">http://ubuntuforums.org/showthread.php?t=842698</a>.</p> <p>russlar provides a solution:</p> <blockquote> <p>open terminal, and run <code>df -h</code>. this will tell you all the hard dri...
<p>Searching for "Unmount Hard Drive Terminal" yields <a href="http://ubuntuforums.org/showthread.php?t=842698" rel="noreferrer">http://ubuntuforums.org/showthread.php?t=842698</a>.</p> <p>russlar provides a solution:</p> <blockquote> <p>open terminal, and run <code>df -h</code>. this will tell you all the hard dri...
387, 57992
bash, unmount
<h1>Unmount my external hard drive in bash</h1> <p>So, this should apparently be really simple, but had trouble finding any good answers online.</p> <p>I have a mounted external usb hard drive.</p> <p>I would like to unmount it, using bash. (Essentially I'm just looking for the equivalent bash command for right click...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,669
bash
# Unmount my external hard drive in bash So, this should apparently be really simple, but had trouble finding any good answers online. I have a mounted external usb hard drive. I would like to unmount it, using bash. (Essentially I'm just looking for the equivalent bash command for right clicking on my external hard...
Searching for "Unmount Hard Drive Terminal" yields <http://ubuntuforums.org/showthread.php?t=842698>. russlar provides a solution: > open terminal, and run `df -h`. this will tell you all the hard drives mounted. then, run `sudo umount /dev/<something>`, where `<something>` is the name of the hard drive that you want...
14482943
Can a string be returned from a Bash function without using echo or global variables?
12
2013-01-23 15:14:52
<p>I'm returning to a lot of Bash scripting at my work, and I'm rusty.</p> <p>Is there a way to return a local value string from a function without making it global or using echo? I want the function to be able to interact with the user via screen, but also pass a return value to a variable without something like <cod...
15,492
1,440,764
2022-02-16 16:38:53
14,483,448
14
2013-01-23 15:40:43
1,301,972
2013-01-23 15:40:43
https://stackoverflow.com/q/14482943
https://stackoverflow.com/a/14483448
<p>No. Bash doesn't return anything other than a numeric exit status from a function. Your choices are:</p> <ol> <li>Set a non-local variable inside the function.</li> <li>Use <code>echo</code>, <code>printf</code>, or similar to provide output. That output can then be assigned outside the function using command subst...
<p>No. Bash doesn't return anything other than a numeric exit status from a function. Your choices are:</p> <ol> <li>Set a non-local variable inside the function.</li> <li>Use <code>echo</code>, <code>printf</code>, or similar to provide output. That output can then be assigned outside the function using command subst...
387, 4063, 4705, 5569, 13824
bash, echo, function, interactive, return
<h1>Can a string be returned from a Bash function without using echo or global variables?</h1> <p>I'm returning to a lot of Bash scripting at my work, and I'm rusty.</p> <p>Is there a way to return a local value string from a function without making it global or using echo? I want the function to be able to interact w...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,670
bash
# Can a string be returned from a Bash function without using echo or global variables? I'm returning to a lot of Bash scripting at my work, and I'm rusty. Is there a way to return a local value string from a function without making it global or using echo? I want the function to be able to interact with the user via...
No. Bash doesn't return anything other than a numeric exit status from a function. Your choices are: 1. Set a non-local variable inside the function. 2. Use `echo`, `printf`, or similar to provide output. That output can then be assigned outside the function using command substitution.
13229642
msysgit sh.exe arguments
12
2012-11-05 09:55:22
<p>I am trying to find some documentation about msysgit sh.exe command.</p> <p>For instance I am aware of the <code>--login</code> flag to launch a git bash session but I would to know the other possibilities.</p> <p>I have looked over the internet but can not find any place where is listed all the possibles argument...
14,639
1,393,890
2016-08-29 20:35:02
13,229,748
14
2012-11-05 10:00:52
216,074
2015-08-24 11:31:30
https://stackoverflow.com/q/13229642
https://stackoverflow.com/a/13229748
<pre><code>&gt; .\sh.exe --help GNU bash, version 3.1.0(1)-release-(i686-pc-msys) Usage: ".../Git/bin/sh.exe" [GNU long option] [option] ... ".../Git/bin/sh.exe" [GNU long option] [option] script-file ... GNU long options: --debug --debugger --dump-po-strings --dump-strings ...
<pre><code>&gt; .\sh.exe --help GNU bash, version 3.1.0(1)-release-(i686-pc-msys) Usage: ".../Git/bin/sh.exe" [GNU long option] [option] ... ".../Git/bin/sh.exe" [GNU long option] [option] script-file ... GNU long options: --debug --debugger --dump-po-strings --dump-strings ...
119, 7002, 10327, 21628
batch-file, git, msysgit, sh
<h1>msysgit sh.exe arguments</h1> <p>I am trying to find some documentation about msysgit sh.exe command.</p> <p>For instance I am aware of the <code>--login</code> flag to launch a git bash session but I would to know the other possibilities.</p> <p>I have looked over the internet but can not find any place where is...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,671
bash
# msysgit sh.exe arguments I am trying to find some documentation about msysgit sh.exe command. For instance I am aware of the `--login` flag to launch a git bash session but I would to know the other possibilities. I have looked over the internet but can not find any place where is listed all the possibles argument...
``` > .\sh.exe --help GNU bash, version 3.1.0(1)-release-(i686-pc-msys) Usage: ".../Git/bin/sh.exe" [GNU long option] [option] ... ".../Git/bin/sh.exe" [GNU long option] [option] script-file ... GNU long options: --debug --debugger --dump-po-strings --dump-strings --help...
13183152
Executing shell-script with parameters from java
12
2012-11-01 18:17:05
<p>I have been googling for some time, and everyone seems to have a different solution, none of which appear to be working for me.</p> <p>I have tried both <code>ProcessBuilder</code> and <code>Runtime</code>. Both calling the <code>.sh</code> file directly and feeding it to <code>/bin/bash</code>. With no luck.</p> ...
36,816
980,520
2012-11-01 21:17:55
13,183,211
14
2012-11-01 18:20:37
978,917
2012-11-01 18:20:37
https://stackoverflow.com/q/13183152
https://stackoverflow.com/a/13183211
<p>One option is to handle <code>~</code> yourself:</p> <pre><code>String homeDir = System.getenv("HOME"); String[] cmd = { homeDir + "/path/to/shellscript.sh", "foo", "bar" }; Process p = Runtime.getRuntime().exec(cmd); </code></pre> <p>Another is to let Bash handle it for you:</p> <pre><code>String[] cmd = { "bash...
<p>One option is to handle <code>~</code> yourself:</p> <pre><code>String homeDir = System.getenv("HOME"); String[] cmd = { homeDir + "/path/to/shellscript.sh", "foo", "bar" }; Process p = Runtime.getRuntime().exec(cmd); </code></pre> <p>Another is to let Bash handle it for you:</p> <pre><code>String[] cmd = { "bash...
17, 387, 4317
bash, java, runtime
<h1>Executing shell-script with parameters from java</h1> <p>I have been googling for some time, and everyone seems to have a different solution, none of which appear to be working for me.</p> <p>I have tried both <code>ProcessBuilder</code> and <code>Runtime</code>. Both calling the <code>.sh</code> file directly and...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,672
bash
# Executing shell-script with parameters from java I have been googling for some time, and everyone seems to have a different solution, none of which appear to be working for me. I have tried both `ProcessBuilder` and `Runtime`. Both calling the `.sh` file directly and feeding it to `/bin/bash`. With no luck. Back t...
One option is to handle `~` yourself: ``` String homeDir = System.getenv("HOME"); String[] cmd = { homeDir + "/path/to/shellscript.sh", "foo", "bar" }; Process p = Runtime.getRuntime().exec(cmd); ``` Another is to let Bash handle it for you: ``` String[] cmd = { "bash", "-c", "~/path/to/shellscript.sh foo bar" }; Pr...
12466177
Assign value to element of an array inside a loop in bash
12
2012-09-17 19:51:00
<p>I would like to modify the value to an element of an array and I don't know the syntax to do it</p> <pre><code>for i in `seq 0 8`; do if [ ${config[$i]} = "value1" ] then config[$i] = "value2" #&lt;- This line fi done </code></pre>
22,162
933,074
2012-09-17 20:01:57
12,466,240
14
2012-09-17 19:56:20
418,413
2012-09-17 20:01:57
https://stackoverflow.com/q/12466177
https://stackoverflow.com/a/12466240
<p>Technically, the only thing broken there is the whitespace. Don't put spaces around your operators in shell syntax:</p> <pre><code>config[$i]="value2" </code></pre> <p>However, there are lots of other little things you may want to think about. For example, if an element of <code>config</code> can contain whitespac...
<p>Technically, the only thing broken there is the whitespace. Don't put spaces around your operators in shell syntax:</p> <pre><code>config[$i]="value2" </code></pre> <p>However, there are lots of other little things you may want to think about. For example, if an element of <code>config</code> can contain whitespac...
387
bash
<h1>Assign value to element of an array inside a loop in bash</h1> <p>I would like to modify the value to an element of an array and I don't know the syntax to do it</p> <pre><code>for i in `seq 0 8`; do if [ ${config[$i]} = "value1" ] then config[$i] = "value2" #&lt;- This line fi done </code></pre...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,673
bash
# Assign value to element of an array inside a loop in bash I would like to modify the value to an element of an array and I don't know the syntax to do it ``` for i in `seq 0 8`; do if [ ${config[$i]} = "value1" ] then config[$i] = "value2" #<- This line fi done ```
Technically, the only thing broken there is the whitespace. Don't put spaces around your operators in shell syntax: ``` config[$i]="value2" ``` However, there are lots of other little things you may want to think about. For example, if an element of `config` can contain whitespace, the test can break. Use quotes or t...
5227428
How to grep and then fail an if-statement on specific output from grep?
12
2011-03-08 01:46:38
<p>Ok I need to find the output that a command gives, notely "gbak: ERROR" and then fail on it. I don't know if I'm going about it the right way, I tried to make if fail if the grep did an output to /dev/null but I couldn't get that working either (probably just poor syntax). I'm sure this is a simple one, please let m...
19,045
437,449
2019-01-11 07:26:26
5,227,447
14
2011-03-08 01:49:28
15,168
2012-04-19 14:11:49
https://stackoverflow.com/q/5227428
https://stackoverflow.com/a/5227447
<p>You don't need the 'test' operator square brackets; just test the exit status of <code>grep</code>:</p> <pre><code>if sudo -u firebird $GBAK_COMMAND | grep -q "gbak: ERROR" then echo "$DATE Unsuccessful $1.gdb Gbak. Incorrect user/password" &gt;&gt; /var/log/messages echo "Failed" exit 1 else echo "pass...
<p>You don't need the 'test' operator square brackets; just test the exit status of <code>grep</code>:</p> <pre><code>if sudo -u firebird $GBAK_COMMAND | grep -q "gbak: ERROR" then echo "$DATE Unsuccessful $1.gdb Gbak. Incorrect user/password" &gt;&gt; /var/log/messages echo "Failed" exit 1 else echo "pass...
379, 387, 1271, 2773
bash, error-handling, grep, if-statement
<h1>How to grep and then fail an if-statement on specific output from grep?</h1> <p>Ok I need to find the output that a command gives, notely "gbak: ERROR" and then fail on it. I don't know if I'm going about it the right way, I tried to make if fail if the grep did an output to /dev/null but I couldn't get that workin...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,674
bash
# How to grep and then fail an if-statement on specific output from grep? Ok I need to find the output that a command gives, notely "gbak: ERROR" and then fail on it. I don't know if I'm going about it the right way, I tried to make if fail if the grep did an output to /dev/null but I couldn't get that working either ...
You don't need the 'test' operator square brackets; just test the exit status of `grep`: ``` if sudo -u firebird $GBAK_COMMAND | grep -q "gbak: ERROR" then echo "$DATE Unsuccessful $1.gdb Gbak. Incorrect user/password" >> /var/log/messages echo "Failed" exit 1 else echo "pass" fi ``` The `-q` option to `g...
2640141
Is there a way to switch Bash or zsh from Emacs mode to vi mode with a keystroke?
12
2010-04-14 18:49:49
<p>I'd like to be able to switch temporarily from emacs mode to vi mode, since vi mode is <em>sometimes</em> better, but I'm usually half-way through typing something before I realize I want to use vi mode.</p> <p>I don't want to switch permanently to vi mode, because I normally prefer emacs mode on the command line, ...
5,808
241,142
2022-12-05 18:23:07
2,641,535
14
2010-04-14 22:36:20
26,428
2010-05-29 02:07:52
https://stackoverflow.com/q/2640141
https://stackoverflow.com/a/2641535
<p>You can create a toggle since the key bindings are separate between vi mode and emacs mode.</p> <pre><code>$ set -o emacs $ bind '"\ee": vi-editing-mode' $ set -o vi $ bind '"\ee": emacs-editing-mode' </code></pre> <p>Now Alt-e (or Esc e) will toggle between modes.</p> <p>Add this somewhere in your definition for...
<p>You can create a toggle since the key bindings are separate between vi mode and emacs mode.</p> <pre><code>$ set -o emacs $ bind '"\ee": vi-editing-mode' $ set -o vi $ bind '"\ee": emacs-editing-mode' </code></pre> <p>Now Alt-e (or Esc e) will toggle between modes.</p> <p>Add this somewhere in your definition for...
387, 1318, 3791
bash, history, zsh
<h1>Is there a way to switch Bash or zsh from Emacs mode to vi mode with a keystroke?</h1> <p>I'd like to be able to switch temporarily from emacs mode to vi mode, since vi mode is <em>sometimes</em> better, but I'm usually half-way through typing something before I realize I want to use vi mode.</p> <p>I don't want t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,675
bash
# Is there a way to switch Bash or zsh from Emacs mode to vi mode with a keystroke? I'd like to be able to switch temporarily from emacs mode to vi mode, since vi mode is *sometimes* better, but I'm usually half-way through typing something before I realize I want to use vi mode. I don't want to switch permanently to...
You can create a toggle since the key bindings are separate between vi mode and emacs mode. ``` $ set -o emacs $ bind '"\ee": vi-editing-mode' $ set -o vi $ bind '"\ee": emacs-editing-mode' ``` Now Alt-e (or Esc e) will toggle between modes. Add this somewhere in your definition for `PS1` so you have an indicator in...
1668661
Is there something odd with PowerShell and forwards slashes?
12
2009-11-03 16:55:06
<p>As far as I know, a forward slash is not a reserved keyword in PowerShell. But running the following in cmd pops up an about dialog</p> <pre><code>"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:about </code></pre> <p>The same in PowerShell gives: </p> <pre><code>'C:\Program Files\TortoiseSVN\bin\Tor...
2,003
5,056
2015-07-14 21:45:47
1,668,693
14
2009-11-03 16:58:48
9,536
2009-11-03 16:58:48
https://stackoverflow.com/q/1668661
https://stackoverflow.com/a/1668693
<p>Put an ampersand character in front of the command</p> <pre><code>&amp;"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:about </code></pre> <p>Otherwise, it thinks you're trying to divide the string literal <code>"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe"</code> by something, but it doesn't kn...
<p>Put an ampersand character in front of the command</p> <pre><code>&amp;"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:about </code></pre> <p>Otherwise, it thinks you're trying to divide the string literal <code>"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe"</code> by something, but it doesn't kn...
526
powershell
<h1>Is there something odd with PowerShell and forwards slashes?</h1> <p>As far as I know, a forward slash is not a reserved keyword in PowerShell. But running the following in cmd pops up an about dialog</p> <pre><code>"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:about </code></pre> <p>The same in Po...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,676
bash
# Is there something odd with PowerShell and forwards slashes? As far as I know, a forward slash is not a reserved keyword in PowerShell. But running the following in cmd pops up an about dialog ``` "C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:about ``` The same in PowerShell gives: ``` 'C:\Program ...
Put an ampersand character in front of the command ``` &"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:about ``` Otherwise, it thinks you're trying to divide the string literal `"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe"` by something, but it doesn't know by what.
472038
How to run MSBuild from Powershell without spawning msbuild.exe process?
12
2009-01-23 06:07:20
<p>I am considering running MSBuild from a Powershell script by tapping directly to the MSBuild assemblies (as opposed to looking up MSBuild install path and starting msbuild.exe as a child process).</p> <p>Has anyone done this? What would be the simplest, most straightforward way to run the build? Are there any pros/...
12,504
23,843
2013-01-30 15:12:47
473,629
14
2009-01-23 16:49:56
23,843
2009-01-23 16:49:56
https://stackoverflow.com/q/472038
https://stackoverflow.com/a/473629
<p>The simplest embedded-build invocation that worked and produced output was:</p> <pre><code>[void][System.Reflection.Assembly]::Load('Microsoft.Build.Engine, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') $engine = New-Object Microsoft.Build.BuildEngine.Engine $engine.RegisterLogger((New-Object ...
<p>The simplest embedded-build invocation that worked and produced output was:</p> <pre><code>[void][System.Reflection.Assembly]::Load('Microsoft.Build.Engine, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') $engine = New-Object Microsoft.Build.BuildEngine.Engine $engine.RegisterLogger((New-Object ...
1, 265, 526
.net, msbuild, powershell
<h1>How to run MSBuild from Powershell without spawning msbuild.exe process?</h1> <p>I am considering running MSBuild from a Powershell script by tapping directly to the MSBuild assemblies (as opposed to looking up MSBuild install path and starting msbuild.exe as a child process).</p> <p>Has anyone done this? What wou...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,677
bash
# How to run MSBuild from Powershell without spawning msbuild.exe process? I am considering running MSBuild from a Powershell script by tapping directly to the MSBuild assemblies (as opposed to looking up MSBuild install path and starting msbuild.exe as a child process). Has anyone done this? What would be the simple...
The simplest embedded-build invocation that worked and produced output was: ``` [void][System.Reflection.Assembly]::Load('Microsoft.Build.Engine, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') $engine = New-Object Microsoft.Build.BuildEngine.Engine $engine.RegisterLogger((New-Object Microsoft.Buil...
64908116
Correct ARCHFLAGS value on Apple Silicon?
11
2020-11-19 08:41:38
<p>On my previous, Intel-based Mac, I used to include</p> <pre><code>export ARCHFLAGS=&quot;-arch x86_64&quot; </code></pre> <p>in my shell resource file. What's the correct compilation flag on the new ARM-based Apple silicon? <code>arm</code>? <code>arm64</code>? <code>arm-64</code>? <code>arm_64</code>? There doesn't...
6,740
159,991
2023-06-01 20:23:24
64,965,210
14
2020-11-23 08:52:52
159,991
2020-11-23 08:52:52
https://stackoverflow.com/q/64908116
https://stackoverflow.com/a/64965210
<p>There's a long discussion <a href="https://gitlab.kitware.com/cmake/cmake/-/issues/20989" rel="noreferrer">over here</a> on this topic. Long story short, they're agreeing on trusting <code>uname -m</code> to provide the correct architecture name.</p> <p>This returns <code>arm64</code>, and given lack of evidence to...
<p>There's a long discussion <a href="https://gitlab.kitware.com/cmake/cmake/-/issues/20989" rel="noreferrer">over here</a> on this topic. Long story short, they're agreeing on trusting <code>uname -m</code> to provide the correct architecture name.</p> <p>This returns <code>arm64</code>, and given lack of evidence to...
369, 390, 147764
apple-silicon, macos, shell
<h1>Correct ARCHFLAGS value on Apple Silicon?</h1> <p>On my previous, Intel-based Mac, I used to include</p> <pre><code>export ARCHFLAGS=&quot;-arch x86_64&quot; </code></pre> <p>in my shell resource file. What's the correct compilation flag on the new ARM-based Apple silicon? <code>arm</code>? <code>arm64</code>? <cod...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,678
bash
# Correct ARCHFLAGS value on Apple Silicon? On my previous, Intel-based Mac, I used to include ``` export ARCHFLAGS="-arch x86_64" ``` in my shell resource file. What's the correct compilation flag on the new ARM-based Apple silicon? `arm`? `arm64`? `arm-64`? `arm_64`? There doesn't seem to be a lot of resources out...
There's a long discussion [over here](https://gitlab.kitware.com/cmake/cmake/-/issues/20989) on this topic. Long story short, they're agreeing on trusting `uname -m` to provide the correct architecture name. This returns `arm64`, and given lack of evidence to the contrary, is probably the correct value.
57318343
virtualenv v16.7.2 powershell activate script: "You must 'source' this script: PS> . .\ENV\Scripts\activate" error
11
2019-08-01 23:53:43
<h1>The Problem</h1> <p>Newest version of virtualenv (16.7.2) on python v.3.7.4 has 4 additional lines for the &quot;activate.ps1&quot; script, which when run on Windows10 powerhsell gives the error: <code>You must 'source' this script: PS&gt; . .\ENV\Scripts\activate</code> How do I fix this? (please note that I have ...
10,072
5,720,652
2024-03-25 20:05:01
57,438,268
14
2019-08-09 23:48:14
712,649
2019-08-09 23:48:14
https://stackoverflow.com/q/57318343
https://stackoverflow.com/a/57438268
<p>Let's have a look at that error message:</p> <blockquote> <p><code>You must 'source' this script: PS&gt; . .\ENV\Scripts\activate</code></p> </blockquote> <p>Hmmmm... - <code>PS&gt;</code> is probably just the prompt, which leaves us with this:</p> <pre><code> . .\ENV\Scripts\activate # ^ # | # Check out th...
<p>Let's have a look at that error message:</p> <blockquote> <p><code>You must 'source' this script: PS&gt; . .\ENV\Scripts\activate</code></p> </blockquote> <p>Hmmmm... - <code>PS&gt;</code> is probably just the prompt, which leaves us with this:</p> <pre><code> . .\ENV\Scripts\activate # ^ # | # Check out th...
16, 526, 14529, 107329
powershell, python, virtualenv, windows-10
<h1>virtualenv v16.7.2 powershell activate script: "You must 'source' this script: PS> . .\ENV\Scripts\activate" error</h1> <h1>The Problem</h1> <p>Newest version of virtualenv (16.7.2) on python v.3.7.4 has 4 additional lines for the &quot;activate.ps1&quot; script, which when run on Windows10 powerhsell gives the err...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,679
bash
# virtualenv v16.7.2 powershell activate script: "You must 'source' this script: PS> . .\ENV\Scripts\activate" error # The Problem Newest version of virtualenv (16.7.2) on python v.3.7.4 has 4 additional lines for the "activate.ps1" script, which when run on Windows10 powerhsell gives the error: `You must 'source' th...
Let's have a look at that error message: > `You must 'source' this script: > PS> . .\ENV\Scripts\activate` Hmmmm... - `PS>` is probably just the prompt, which leaves us with this: ``` . .\ENV\Scripts\activate # ^ # | # Check out this guy ``` That, the lonely `.` in front of the path, that is the *dot-source opera...
55265157
How do I change my Powershell script so that it writes out-file in ANSI - Windows-1252 encoding?
11
2019-03-20 16:00:18
<p>I have a banking application script that generates a “filtered” output file by removing error records from a daily input bank file (see <a href="https://stackoverflow.com/q/52825928/10490903">How do I create a Windows Server script to remove error records, AND the previous record to each, from a file with the result...
17,962
10,490,903
2023-07-25 22:39:13
55,266,321
14
2019-03-20 16:59:29
45,375
2023-07-25 22:39:13
https://stackoverflow.com/q/55265157
https://stackoverflow.com/a/55266321
<p>Note:</p> <ul> <li><p>You later clarified that you need LF (Unix-format) newlines - see the bottom section.</p> </li> <li><p>The next section deals with the question as originally asked and presents solutions that result in files with CRLF (Windows-format) newlines when run on Windows.</p> </li> </ul> <hr /> <p><st...
<p>Note:</p> <ul> <li><p>You later clarified that you need LF (Unix-format) newlines - see the bottom section.</p> </li> <li><p>The next section deals with the question as originally asked and presents solutions that result in files with CRLF (Windows-format) newlines when run on Windows.</p> </li> </ul> <hr /> <p><st...
526
powershell
<h1>How do I change my Powershell script so that it writes out-file in ANSI - Windows-1252 encoding?</h1> <p>I have a banking application script that generates a “filtered” output file by removing error records from a daily input bank file (see <a href="https://stackoverflow.com/q/52825928/10490903">How do I create a W...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,680
bash
# How do I change my Powershell script so that it writes out-file in ANSI - Windows-1252 encoding? I have a banking application script that generates a “filtered” output file by removing error records from a daily input bank file (see [How do I create a Windows Server script to remove error records, AND the previous r...
Note: - You later clarified that you need LF (Unix-format) newlines - see the bottom section. - The next section deals with the question as originally asked and presents solutions that result in files with CRLF (Windows-format) newlines when run on Windows. --- ***If* your system's [*Language for non-Unicode program...
43253453
Get Function & Host Keys of Azure Function In Powershell
11
2017-04-06 11:11:13
<p>I have deployed Azure function using Arm template. I need the Function Key &amp; host Key of deployed Azure Function in Powershell. Currently I am trying to get the keys From Output Section of ARM template </p> <pre><code> "outputs": { "FunctionAppName": { "type": "string", "value": "[variables('functionAppName...
13,930
6,902,938
2021-12-07 18:03:44
44,117,841
14
2017-05-22 16:26:37
636,828
2017-05-22 16:26:37
https://stackoverflow.com/q/43253453
https://stackoverflow.com/a/44117841
<p>I got it working by using the following:</p> <pre><code> "outputs": { "FunctionAppName": { "type": "string", "value": "[parameters('functionName')]" }, "Key": { "type": "string", "value": "[listsecrets(resourceId('Microsoft.Web/sites/functions', parameters('existingFun...
<p>I got it working by using the following:</p> <pre><code> "outputs": { "FunctionAppName": { "type": "string", "value": "[parameters('functionName')]" }, "Key": { "type": "string", "value": "[listsecrets(resourceId('Microsoft.Web/sites/functions', parameters('existingFun...
526, 14158
azure, powershell
<h1>Get Function & Host Keys of Azure Function In Powershell</h1> <p>I have deployed Azure function using Arm template. I need the Function Key &amp; host Key of deployed Azure Function in Powershell. Currently I am trying to get the keys From Output Section of ARM template </p> <pre><code> "outputs": { "FunctionAppNa...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,681
bash
# Get Function & Host Keys of Azure Function In Powershell I have deployed Azure function using Arm template. I need the Function Key & host Key of deployed Azure Function in Powershell. Currently I am trying to get the keys From Output Section of ARM template ``` "outputs": { "FunctionAppName": { "type": "string"...
I got it working by using the following: ``` "outputs": { "FunctionAppName": { "type": "string", "value": "[parameters('functionName')]" }, "Key": { "type": "string", "value": "[listsecrets(resourceId('Microsoft.Web/sites/functions', parameters('existingFunctionAppName')...
42022194
PowerShell ScriptBlock variable scope
11
2017-02-03 10:34:03
<p>I'm having trouble understanding scopes within <code>ScriptBlock</code>s. I was counting on some kind of closure-like system, but I can't seem to get it working.</p> <p>I have a <code>ScriptBlock</code> that takes a <code>param</code> and returns another <code>ScriptBlock</code>:</p> <pre><code>$sb1 = { Param...
3,988
1,099,948
2018-09-13 23:43:53
42,022,505
14
2017-02-03 10:50:46
73,070
2017-02-03 10:50:46
https://stackoverflow.com/q/42022194
https://stackoverflow.com/a/42022505
<p>You need to explicitly <a href="https://blogs.technet.microsoft.com/heyscriptingguy/2013/04/05/closures-in-powershell/" rel="noreferrer">create a closure</a>:</p> <pre><code>$sb1 = { Param($Message1); Write-Host $Message1; { Param($Message2); Write-Host ($Message1 + " " + $Message2); ...
<p>You need to explicitly <a href="https://blogs.technet.microsoft.com/heyscriptingguy/2013/04/05/closures-in-powershell/" rel="noreferrer">create a closure</a>:</p> <pre><code>$sb1 = { Param($Message1); Write-Host $Message1; { Param($Message2); Write-Host ($Message1 + " " + $Message2); ...
526, 1680, 2182, 91491
closures, powershell, scope, scriptblock
<h1>PowerShell ScriptBlock variable scope</h1> <p>I'm having trouble understanding scopes within <code>ScriptBlock</code>s. I was counting on some kind of closure-like system, but I can't seem to get it working.</p> <p>I have a <code>ScriptBlock</code> that takes a <code>param</code> and returns another <code>ScriptB...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,682
bash
# PowerShell ScriptBlock variable scope I'm having trouble understanding scopes within `ScriptBlock`s. I was counting on some kind of closure-like system, but I can't seem to get it working. I have a `ScriptBlock` that takes a `param` and returns another `ScriptBlock`: ``` $sb1 = { Param($Message1); Write-Ho...
You need to explicitly [create a closure](https://blogs.technet.microsoft.com/heyscriptingguy/2013/04/05/closures-in-powershell/): ``` $sb1 = { Param($Message1); Write-Host $Message1; { Param($Message2); Write-Host ($Message1 + " " + $Message2); }.GetNewClosure() } ``` It then works fo...
41155486
Appending to $PATH vs using aliases: Which is better?
11
2016-12-15 02:35:39
<p>In at least some cases, aliases and adding $PATH locations can be used interchangeably. For example, looking at the python tool <a href="https://github.com/couchapp/couchapp" rel="noreferrer">couchapp</a>, I need to either alias the executable (<a href="https://github.com/couchapp/couchapp/pull/240" rel="noreferrer"...
6,232
3,114,742
2016-12-15 04:58:58
41,156,387
14
2016-12-15 04:22:29
45,375
2016-12-15 04:58:58
https://stackoverflow.com/q/41155486
https://stackoverflow.com/a/41156387
<ul> <li><p><strong>An alias is a <em>shell</em> feature</strong>: any environment that invokes utilities <em>directly</em>, without involving a <em>shell</em> will <em>not</em> see aliases.</p> <ul> <li>Note: Even when calling <em>shell</em> commands from languages such as Python (using, e.g., <code>os.system()</code...
<ul> <li><p><strong>An alias is a <em>shell</em> feature</strong>: any environment that invokes utilities <em>directly</em>, without involving a <em>shell</em> will <em>not</em> see aliases.</p> <ul> <li>Note: Even when calling <em>shell</em> commands from languages such as Python (using, e.g., <code>os.system()</code...
387, 1448, 6268
alias, bash, path
<h1>Appending to $PATH vs using aliases: Which is better?</h1> <p>In at least some cases, aliases and adding $PATH locations can be used interchangeably. For example, looking at the python tool <a href="https://github.com/couchapp/couchapp" rel="noreferrer">couchapp</a>, I need to either alias the executable (<a href="...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,683
bash
# Appending to $PATH vs using aliases: Which is better? In at least some cases, aliases and adding $PATH locations can be used interchangeably. For example, looking at the python tool [couchapp](https://github.com/couchapp/couchapp), I need to either alias the executable ([as helpfully described here](https://github.c...
- **An alias is a *shell* feature**: any environment that invokes utilities *directly*, without involving a *shell* will *not* see aliases. - Note: Even when calling *shell* commands from languages such as Python (using, e.g., `os.system()`), user-specific shell initialization files are typically *not* called, so us...
40915420
How to expand variable in powershell?
11
2016-12-01 16:15:09
<pre><code>Get-WmiObject -Class win32_logicaldisk -Filter 'DeviceID="C:"' </code></pre> <p>does what I want,</p> <pre><code>$var="C:" Get-WmiObject -Class win32_logicaldisk -Filter 'DeviceID="{$var}"' </code></pre> <p>does nothing. I tried to change the quotes, to concatenate strings, and other 1000 things, but they...
31,903
2,511,976
2020-05-20 11:36:09
40,915,788
14
2016-12-01 16:33:48
712,649
2016-12-01 16:33:48
https://stackoverflow.com/q/40915420
https://stackoverflow.com/a/40915788
<p>When you start a string literal with <code>'</code> (single-quotes), you're creating a verbatim string - that is, every character inside the string is interpreted literally and variable references and expressions won't expand!</p> <p>Use <code>"</code> if you want the variable to be expanded:</p> <pre><code>$var =...
<p>When you start a string literal with <code>'</code> (single-quotes), you're creating a verbatim string - that is, every character inside the string is interpreted literally and variable references and expressions won't expand!</p> <p>Use <code>"</code> if you want the variable to be expanded:</p> <pre><code>$var =...
526
powershell
<h1>How to expand variable in powershell?</h1> <pre><code>Get-WmiObject -Class win32_logicaldisk -Filter 'DeviceID="C:"' </code></pre> <p>does what I want,</p> <pre><code>$var="C:" Get-WmiObject -Class win32_logicaldisk -Filter 'DeviceID="{$var}"' </code></pre> <p>does nothing. I tried to change the quotes, to conca...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,684
bash
# How to expand variable in powershell? ``` Get-WmiObject -Class win32_logicaldisk -Filter 'DeviceID="C:"' ``` does what I want, ``` $var="C:" Get-WmiObject -Class win32_logicaldisk -Filter 'DeviceID="{$var}"' ``` does nothing. I tried to change the quotes, to concatenate strings, and other 1000 things, but they di...
When you start a string literal with `'` (single-quotes), you're creating a verbatim string - that is, every character inside the string is interpreted literally and variable references and expressions won't expand! Use `"` if you want the variable to be expanded: ``` $var = 'C:' Get-WmiObject -Class win32_logicaldis...
13916794
Django shell: Command to load test fixture data?
11
2012-12-17 15:15:49
<p>Is there an easy way to load fixture data that I usually use in automated test runs in the interactive Django shell?</p> <p>It might be awkward to have a mixture of model data that come from the database and others that come from a fixture. In my case, I have some read-only tables and wand to experiment with some d...
7,753
996,247
2016-11-13 00:06:48
40,063,425
14
2016-10-15 19:39:05
6,839,055
2016-11-13 00:06:48
https://stackoverflow.com/q/13916794
https://stackoverflow.com/a/40063425
<p>ilardm's answer points in the right direction, specifically what you want is:</p> <pre><code>from django.core.management import call_command call_command('loaddata', 'fixture_name.json') </code></pre> <p>Edit: But the correct way to include fixtures in test cases is like this:</p> <pre><code>class TestThis(TestCa...
<p>ilardm's answer points in the right direction, specifically what you want is:</p> <pre><code>from django.core.management import call_command call_command('loaddata', 'fixture_name.json') </code></pre> <p>Edit: But the correct way to include fixtures in test cases is like this:</p> <pre><code>class TestThis(TestCa...
243, 390
django, shell
<h1>Django shell: Command to load test fixture data?</h1> <p>Is there an easy way to load fixture data that I usually use in automated test runs in the interactive Django shell?</p> <p>It might be awkward to have a mixture of model data that come from the database and others that come from a fixture. In my case, I hav...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,685
bash
# Django shell: Command to load test fixture data? Is there an easy way to load fixture data that I usually use in automated test runs in the interactive Django shell? It might be awkward to have a mixture of model data that come from the database and others that come from a fixture. In my case, I have some read-only...
ilardm's answer points in the right direction, specifically what you want is: ``` from django.core.management import call_command call_command('loaddata', 'fixture_name.json') ``` Edit: But the correct way to include fixtures in test cases is like this: ``` class TestThis(TestCase): fixtures = ['myfixture.json']...
37724769
How to install a PowerShell module in an Azure Function
11
2016-06-09 11:31:33
<p>I need the AWS module, which is available from the PS-Gallery but when I try to run the install step inside an <a href="https://azure.microsoft.com/en-us/services/functions/" rel="noreferrer">Azure Function</a>, it doesn't work. The -verbose argument flag isn't writing anything to the console. </p> <p>What is the r...
17,284
2,257,093
2017-12-14 11:49:49
39,985,646
14
2016-10-11 19:56:30
6,465,830
2016-10-15 07:53:38
https://stackoverflow.com/q/37724769
https://stackoverflow.com/a/39985646
<p>Azure Functions support for PowerShell scripting is currently in an experimental stage. The following scenarios are supported:</p> <ol> <li>Azure Functions will be able to support customers bringing their own modules. These modules will reside in a folder named <code>modules</code> that is located in the same dir...
<p>Azure Functions support for PowerShell scripting is currently in an experimental stage. The following scenarios are supported:</p> <ol> <li>Azure Functions will be able to support customers bringing their own modules. These modules will reside in a folder named <code>modules</code> that is located in the same dir...
526, 14158, 118870
azure, azure-functions, powershell
<h1>How to install a PowerShell module in an Azure Function</h1> <p>I need the AWS module, which is available from the PS-Gallery but when I try to run the install step inside an <a href="https://azure.microsoft.com/en-us/services/functions/" rel="noreferrer">Azure Function</a>, it doesn't work. The -verbose argument f...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,686
bash
# How to install a PowerShell module in an Azure Function I need the AWS module, which is available from the PS-Gallery but when I try to run the install step inside an [Azure Function](https://azure.microsoft.com/en-us/services/functions/), it doesn't work. The -verbose argument flag isn't writing anything to the con...
Azure Functions support for PowerShell scripting is currently in an experimental stage. The following scenarios are supported: 1. Azure Functions will be able to support customers bringing their own modules. These modules will reside in a folder named `modules` that is located in the same directory where the PowerShel...
38281709
How to suppress npm WARN deprecated messages in bash
11
2016-07-09 12:14:04
<p>I have several version of <code>node.js</code> installed in Linux Mint 18.0. I manage them using <code>nvm</code>. Because of a project dependency, I need to have version 0.10 as the default version (<code>nvm use 0.10</code>). As a result of this, every time I start my terminal, I get the following output:</p> <pr...
24,894
1,836,143
2021-12-07 12:44:53
38,281,927
14
2016-07-09 12:43:57
114,770
2016-07-09 12:43:57
https://stackoverflow.com/q/38281709
https://stackoverflow.com/a/38281927
<p>You can suppress or quieten NPM via an environment variable:</p> <pre><code>npm_config_loglevel=silent npm version </code></pre> <p>This should work in your <code>.bashrc</code> (or wherever you invoke <code>nvm</code>):</p> <pre><code>npm_config_loglevel=silent nvm use 0.10 </code></pre> <p>Or you can set the e...
<p>You can suppress or quieten NPM via an environment variable:</p> <pre><code>npm_config_loglevel=silent npm version </code></pre> <p>This should work in your <code>.bashrc</code> (or wherever you invoke <code>nvm</code>):</p> <pre><code>npm_config_loglevel=silent nvm use 0.10 </code></pre> <p>Or you can set the e...
58, 387, 46426, 61387
bash, linux, node.js, npm
<h1>How to suppress npm WARN deprecated messages in bash</h1> <p>I have several version of <code>node.js</code> installed in Linux Mint 18.0. I manage them using <code>nvm</code>. Because of a project dependency, I need to have version 0.10 as the default version (<code>nvm use 0.10</code>). As a result of this, every ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,687
bash
# How to suppress npm WARN deprecated messages in bash I have several version of `node.js` installed in Linux Mint 18.0. I manage them using `nvm`. Because of a project dependency, I need to have version 0.10 as the default version (`nvm use 0.10`). As a result of this, every time I start my terminal, I get the follow...
You can suppress or quieten NPM via an environment variable: ``` npm_config_loglevel=silent npm version ``` This should work in your `.bashrc` (or wherever you invoke `nvm`): ``` npm_config_loglevel=silent nvm use 0.10 ``` Or you can set the environment variable globally ``` export npm_config_loglevel=silent ``` ...
34216850
How to prevent Fish shell from closing when typing Ctrl-D (EOF)
11
2015-12-11 05:41:57
<p>I am using fish shell. When I type Ctrl-D, it sends a EOF to my terminal and then terminal closes.</p> <p>I want to make it such that ctrl-D does not close my iterm2.</p> <p>I saw that people have set up IGNOREEOF in bash shell like this: <a href="https://unix.stackexchange.com/questions/27588/how-can-i-keep-contr...
5,548
4,251,307
2022-09-28 17:52:09
34,218,767
14
2015-12-11 08:09:10
1,441,328
2015-12-11 08:09:10
https://stackoverflow.com/q/34216850
https://stackoverflow.com/a/34218767
<p>This is the default key binding for control-D:</p> <pre><code>bind \cd delete-or-exit </code></pre> <p>you can find this by just running <code>bind</code>.</p> <p>(<code>delete-or-exit</code> is just a function, which you can read with <code>functions delete-or-exit</code>.)</p> <p>So it's exiting because that's...
<p>This is the default key binding for control-D:</p> <pre><code>bind \cd delete-or-exit </code></pre> <p>you can find this by just running <code>bind</code>.</p> <p>(<code>delete-or-exit</code> is just a function, which you can read with <code>functions delete-or-exit</code>.)</p> <p>So it's exiting because that's...
34, 390, 55824
fish, shell, unix
<h1>How to prevent Fish shell from closing when typing Ctrl-D (EOF)</h1> <p>I am using fish shell. When I type Ctrl-D, it sends a EOF to my terminal and then terminal closes.</p> <p>I want to make it such that ctrl-D does not close my iterm2.</p> <p>I saw that people have set up IGNOREEOF in bash shell like this: <a ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,688
bash
# How to prevent Fish shell from closing when typing Ctrl-D (EOF) I am using fish shell. When I type Ctrl-D, it sends a EOF to my terminal and then terminal closes. I want to make it such that ctrl-D does not close my iterm2. I saw that people have set up IGNOREEOF in bash shell like this: <https://unix.stackexchang...
This is the default key binding for control-D: ``` bind \cd delete-or-exit ``` you can find this by just running `bind`. (`delete-or-exit` is just a function, which you can read with `functions delete-or-exit`.) So it's exiting because that's what the default behavior is. You can make control-D do something else. F...
33631255
How to escape & in scp
11
2015-11-10 13:34:51
<p>Yes, I do realize it has been asked a thousand of times how to escape <strong>spaces</strong> in scp, but I fail to do that with the <em>&amp;</em>-sign, so if that sign is part of the directory name.</p> <pre><code>[sorunome@sorunome-desktop tmp]$ scp test.txt "bpi:/home/sorunome/test &amp; stuff" zsh:1: command n...
12,288
2,014,411
2022-12-23 15:13:19
33,632,377
14
2015-11-10 14:30:44
1,678,362
2015-11-10 14:30:44
https://stackoverflow.com/q/33631255
https://stackoverflow.com/a/33632377
<p>Escaping both the spaces and the ampersand did the trick for me :</p> <pre><code>scp source_file "user@host:/dir\ with\ spaces\ \&amp;\ ampersand" </code></pre> <p>The quotes are still needed for some reason.</p>
<p>Escaping both the spaces and the ampersand did the trick for me :</p> <pre><code>scp source_file "user@host:/dir\ with\ spaces\ \&amp;\ ampersand" </code></pre> <p>The quotes are still needed for some reason.</p>
390, 3149, 4804
escaping, scp, shell
<h1>How to escape & in scp</h1> <p>Yes, I do realize it has been asked a thousand of times how to escape <strong>spaces</strong> in scp, but I fail to do that with the <em>&amp;</em>-sign, so if that sign is part of the directory name.</p> <pre><code>[sorunome@sorunome-desktop tmp]$ scp test.txt "bpi:/home/sorunome/te...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,689
bash
# How to escape & in scp Yes, I do realize it has been asked a thousand of times how to escape **spaces** in scp, but I fail to do that with the *&*-sign, so if that sign is part of the directory name. ``` [sorunome@sorunome-desktop tmp]$ scp test.txt "bpi:/home/sorunome/test & stuff" zsh:1: command not found: stuff ...
Escaping both the spaces and the ampersand did the trick for me : ``` scp source_file "user@host:/dir\ with\ spaces\ \&\ ampersand" ``` The quotes are still needed for some reason.
32101010
Run a Powershell command (not script) from Excel VBA
11
2015-08-19 16:30:21
<p>I've searched SO, and I can find plenty of examples of running a PowerShell script from VBA, but I can't find any examples of just running a simple command.</p> <p>For example, this works:</p> <pre><code>Dim retval As Variant retval = Shell("PowerShell ""C:\MyScript.ps1""", vbNormalFocus) </code></pre> <p>But thi...
40,264
5,094,258
2015-08-19 17:29:31
32,101,992
14
2015-08-19 17:29:31
2,237,785
2015-08-19 17:29:31
https://stackoverflow.com/q/32101010
https://stackoverflow.com/a/32101992
<p>To run an inline Powershell command, you'll probably need to use the <code>-Command</code> param and surround your statement with quotes. It'll also be easier if you use single quotes within the command.</p> <p>Try this out:</p> <pre><code>pscmd = "PowerShell -Command ""{Get-ScheduledTask -TaskName 'My Task' -CimS...
<p>To run an inline Powershell command, you'll probably need to use the <code>-Command</code> param and surround your statement with quotes. It'll also be easier if you use single quotes within the command.</p> <p>Try this out:</p> <pre><code>pscmd = "PowerShell -Command ""{Get-ScheduledTask -TaskName 'My Task' -CimS...
526, 1449
powershell, vba
<h1>Run a Powershell command (not script) from Excel VBA</h1> <p>I've searched SO, and I can find plenty of examples of running a PowerShell script from VBA, but I can't find any examples of just running a simple command.</p> <p>For example, this works:</p> <pre><code>Dim retval As Variant retval = Shell("PowerShell ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,690
bash
# Run a Powershell command (not script) from Excel VBA I've searched SO, and I can find plenty of examples of running a PowerShell script from VBA, but I can't find any examples of just running a simple command. For example, this works: ``` Dim retval As Variant retval = Shell("PowerShell ""C:\MyScript.ps1""", vbNor...
To run an inline Powershell command, you'll probably need to use the `-Command` param and surround your statement with quotes. It'll also be easier if you use single quotes within the command. Try this out: ``` pscmd = "PowerShell -Command ""{Get-ScheduledTask -TaskName 'My Task' -CimSession MYLAPTOP}""" ```
29307941
Cannot overwrite variable because it is readonly
11
2015-03-27 18:40:16
<p>I am trying to learn Powershell. I have the following script:</p> <pre><code>$cmd = { param($pid) Write-Host $pid } $processes = Get-Process -Name notepad foreach ($process in $processes) { $pid = $process.ID Start-Job -ScriptBlock $cmd -ArgumentList $pid } </code></pre> <p>I'm getting the following...
31,139
4,187,557
2015-03-27 23:41:41
29,307,990
14
2015-03-27 18:43:19
574,168
2015-03-27 20:20:08
https://stackoverflow.com/q/29307941
https://stackoverflow.com/a/29307990
<p><code>$PID</code> is a <a href="https://technet.microsoft.com/en-us/library/hh847768.aspx" rel="noreferrer">reserved, automatic variable</a> that contains the process id of your session. You cannot set it.</p> <p>See:</p> <pre><code>Get-Help about_Automatic_Variables </code></pre> <p>for a complete list and des...
<p><code>$PID</code> is a <a href="https://technet.microsoft.com/en-us/library/hh847768.aspx" rel="noreferrer">reserved, automatic variable</a> that contains the process id of your session. You cannot set it.</p> <p>See:</p> <pre><code>Get-Help about_Automatic_Variables </code></pre> <p>for a complete list and des...
64, 526
powershell, windows
<h1>Cannot overwrite variable because it is readonly</h1> <p>I am trying to learn Powershell. I have the following script:</p> <pre><code>$cmd = { param($pid) Write-Host $pid } $processes = Get-Process -Name notepad foreach ($process in $processes) { $pid = $process.ID Start-Job -ScriptBlock $cmd -Argum...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,691
bash
# Cannot overwrite variable because it is readonly I am trying to learn Powershell. I have the following script: ``` $cmd = { param($pid) Write-Host $pid } $processes = Get-Process -Name notepad foreach ($process in $processes) { $pid = $process.ID Start-Job -ScriptBlock $cmd -ArgumentList $pid } ``` ...
`$PID` is a [reserved, automatic variable](https://technet.microsoft.com/en-us/library/hh847768.aspx) that contains the process id of your session. You cannot set it. See: ``` Get-Help about_Automatic_Variables ``` for a complete list and description of the automatic variables. Edit: To output the process ID's of ...
29082699
How to find all files and separate results by comma on Unix?
11
2015-03-16 17:01:07
<p>I would like to go from the standard <code>find</code> output which is:</p> <pre><code>path/to/file1.yaml path/to/file2.yaml path/to/file3.yaml </code></pre> <p>To this:</p> <pre><code>path/to/file1.yaml,path/to/file2.yaml,path/to/file3.yaml </code></pre> <p>What's the simplest way to do that from the command li...
9,864
169,992
2017-10-24 18:32:19
29,082,792
14
2015-03-16 17:06:15
3,030,305
2017-10-24 18:32:19
https://stackoverflow.com/q/29082699
https://stackoverflow.com/a/29082792
<p>Here is one approach for separating the filenames with commas:</p> <pre><code>find . -path '*.yaml' | tr '\n' ',' </code></pre> <p>If the file names do not contain white space, then another approach is:</p> <pre><code>IFS=, echo $(find . -path '*.yaml') </code></pre> <p>In the comments, <a href="https://stackove...
<p>Here is one approach for separating the filenames with commas:</p> <pre><code>find . -path '*.yaml' | tr '\n' ',' </code></pre> <p>If the file names do not contain white space, then another approach is:</p> <pre><code>IFS=, echo $(find . -path '*.yaml') </code></pre> <p>In the comments, <a href="https://stackove...
34, 387, 390
bash, shell, unix
<h1>How to find all files and separate results by comma on Unix?</h1> <p>I would like to go from the standard <code>find</code> output which is:</p> <pre><code>path/to/file1.yaml path/to/file2.yaml path/to/file3.yaml </code></pre> <p>To this:</p> <pre><code>path/to/file1.yaml,path/to/file2.yaml,path/to/file3.yaml </...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,692
bash
# How to find all files and separate results by comma on Unix? I would like to go from the standard `find` output which is: ``` path/to/file1.yaml path/to/file2.yaml path/to/file3.yaml ``` To this: ``` path/to/file1.yaml,path/to/file2.yaml,path/to/file3.yaml ``` What's the simplest way to do that from the command ...
Here is one approach for separating the filenames with commas: ``` find . -path '*.yaml' | tr '\n' ',' ``` If the file names do not contain white space, then another approach is: ``` IFS=, echo $(find . -path '*.yaml') ``` In the comments, [Kojiro](https://stackoverflow.com/users/418413/kojiro) suggests a third app...
28763707
Powershell apply verbosity at a global level
11
2015-02-27 11:11:24
<p>Imagine if you have a script containing a single line of code like </p> <pre><code>ni -type file foobar.txt </code></pre> <p>where the -verbose flag is not supplied to the ni command. Is there a way to set the Verbosity at a global PSSession level if I were to run this script to force verbosity? The reason I ask i...
4,691
1,054,637
2020-09-08 17:35:29
28,763,976
14
2015-02-27 11:24:54
574,168
2015-02-27 14:10:08
https://stackoverflow.com/q/28763707
https://stackoverflow.com/a/28763976
<p>Use <code>$PSDefaultParameterValues</code>:</p> <pre><code>$PSDefaultParameterValues['New-Item:Verbose'] = $true </code></pre> <p>Set that in the Global scope, and then the default value of -Verbose for the New-Item cmdlet will be $True.</p> <p>You can use wildcards for the cmdletsyou want to affect:</p> <pre><c...
<p>Use <code>$PSDefaultParameterValues</code>:</p> <pre><code>$PSDefaultParameterValues['New-Item:Verbose'] = $true </code></pre> <p>Set that in the Global scope, and then the default value of -Verbose for the New-Item cmdlet will be $True.</p> <p>You can use wildcards for the cmdletsyou want to affect:</p> <pre><c...
526, 35061
powershell, verbose
<h1>Powershell apply verbosity at a global level</h1> <p>Imagine if you have a script containing a single line of code like </p> <pre><code>ni -type file foobar.txt </code></pre> <p>where the -verbose flag is not supplied to the ni command. Is there a way to set the Verbosity at a global PSSession level if I were to ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,693
bash
# Powershell apply verbosity at a global level Imagine if you have a script containing a single line of code like ``` ni -type file foobar.txt ``` where the -verbose flag is not supplied to the ni command. Is there a way to set the Verbosity at a global PSSession level if I were to run this script to force verbosity...
Use `$PSDefaultParameterValues`: ``` $PSDefaultParameterValues['New-Item:Verbose'] = $true ``` Set that in the Global scope, and then the default value of -Verbose for the New-Item cmdlet will be $True. You can use wildcards for the cmdletsyou want to affect: ``` $PSDefaultParameterValues['New-*:Verbose'] = $true `...
27304469
Capturing the output of "diff" with org-babel
11
2014-12-04 21:30:13
<p>I'm trying to capture the output of <code>diff</code> with org-babel, but for some reason it's not working. For the files</p> <p>1</p> <pre><code>a b c </code></pre> <p>2</p> <pre><code>a c b </code></pre> <p><code>diff 1 2</code> called from the command line returns</p> <pre><code>1c1 &lt; a b c --- &gt; a c ...
2,302
2,032,568
2020-01-28 02:07:15
27,315,285
14
2014-12-05 11:49:30
605,276
2014-12-05 11:49:30
https://stackoverflow.com/q/27304469
https://stackoverflow.com/a/27315285
<p>I could reproduce your problem (on OSX).</p> <p>The strange thing is that executing the babel block will open the <em>Org-babel Error Output</em> buffer, as if something were going to STDERR.</p> <p>If you add any other output after diff, results will display OK. For example,</p> <pre><code>#+begin_src sh :result...
<p>I could reproduce your problem (on OSX).</p> <p>The strange thing is that executing the babel block will open the <em>Org-babel Error Output</em> buffer, as if something were going to STDERR.</p> <p>If you add any other output after diff, results will display OK. For example,</p> <pre><code>#+begin_src sh :result...
371, 10327, 27401, 71029
emacs, org-babel, org-mode, sh
<h1>Capturing the output of "diff" with org-babel</h1> <p>I'm trying to capture the output of <code>diff</code> with org-babel, but for some reason it's not working. For the files</p> <p>1</p> <pre><code>a b c </code></pre> <p>2</p> <pre><code>a c b </code></pre> <p><code>diff 1 2</code> called from the command li...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,694
bash
# Capturing the output of "diff" with org-babel I'm trying to capture the output of `diff` with org-babel, but for some reason it's not working. For the files 1 ``` a b c ``` 2 ``` a c b ``` `diff 1 2` called from the command line returns ``` 1c1 < a b c --- > a c b ``` But with org-babel, nothing: ``` #+begin...
I could reproduce your problem (on OSX). The strange thing is that executing the babel block will open the *Org-babel Error Output* buffer, as if something were going to STDERR. If you add any other output after diff, results will display OK. For example, ``` #+begin_src sh :results output diff 1 2 echo #+end_src ``...
26315734
Difference between select-object and using foreach on the same object
11
2014-10-11 14:31:59
<p>Can someone please help me understand the difference between the below two pieces of code . Why are the results different for both . I each case i am selecting the same property (name) :</p> <p>Code 1 :</p> <pre><code>$obj = Get-Service | Where-Object {$_.Status -eq "Running"} | foreach-object {$_.Name} | select ...
16,931
1,867,151
2021-06-23 13:03:08
26,316,287
14
2014-10-11 15:36:06
361,842
2021-06-23 13:03:08
https://stackoverflow.com/q/26315734
https://stackoverflow.com/a/26316287
<p>Select-Object returns an array of custom objects to the pipeline; in this case having only one property which happens to be a string.<br /> As @walidtourni mentions, using <code>expand</code> works around this issue. This is because <code>expand</code> causes the output to be the property's value, instead of a cust...
<p>Select-Object returns an array of custom objects to the pipeline; in this case having only one property which happens to be a string.<br /> As @walidtourni mentions, using <code>expand</code> works around this issue. This is because <code>expand</code> causes the output to be the property's value, instead of a cust...
526
powershell
<h1>Difference between select-object and using foreach on the same object</h1> <p>Can someone please help me understand the difference between the below two pieces of code . Why are the results different for both . I each case i am selecting the same property (name) :</p> <p>Code 1 :</p> <pre><code>$obj = Get-Service...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,695
bash
# Difference between select-object and using foreach on the same object Can someone please help me understand the difference between the below two pieces of code . Why are the results different for both . I each case i am selecting the same property (name) : Code 1 : ``` $obj = Get-Service | Where-Object {$_.Status ...
Select-Object returns an array of custom objects to the pipeline; in this case having only one property which happens to be a string. As @walidtourni mentions, using `expand` works around this issue. This is because `expand` causes the output to be the property's value, instead of a custom object with a property with...
25314140
JMeter / Beanshell "Error invoking bsh method: eval Sourced file:"
11
2014-08-14 17:34:23
<p>I'm having an issue in JMeter wherein I receive this error </p> <pre><code>2014/08/14 14:13:26 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``String RequestUrl = vars.get("RequestUrl"); String[] params = RequestUrl.split(" . . . '' : Typed variable ...
43,223
3,942,348
2017-09-05 11:34:52
25,339,463
14
2014-08-16 10:56:28
2,897,748
2014-08-16 10:56:28
https://stackoverflow.com/q/25314140
https://stackoverflow.com/a/25339463
<p>I don't see your URL and what does XPath query return but in any case your URL parsing logic looks flaky as it strongly dependent on parameters order and presence and may bite you back in future in case of request URL change i.e. extra parameter or changed parameters order or something encoded, etc. </p> <p>See bel...
<p>I don't see your URL and what does XPath query return but in any case your URL parsing logic looks flaky as it strongly dependent on parameters order and presence and may bite you back in future in case of request URL change i.e. extra parameter or changed parameters order or something encoded, etc. </p> <p>See bel...
8401, 13554
beanshell, jmeter
<h1>JMeter / Beanshell "Error invoking bsh method: eval Sourced file:"</h1> <p>I'm having an issue in JMeter wherein I receive this error </p> <pre><code>2014/08/14 14:13:26 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``String RequestUrl = vars.get("R...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,696
bash
# JMeter / Beanshell "Error invoking bsh method: eval Sourced file:" I'm having an issue in JMeter wherein I receive this error ``` 2014/08/14 14:13:26 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``String RequestUrl = vars.get("RequestUrl"); String[]...
I don't see your URL and what does XPath query return but in any case your URL parsing logic looks flaky as it strongly dependent on parameters order and presence and may bite you back in future in case of request URL change i.e. extra parameter or changed parameters order or something encoded, etc. See below for refe...
24771402
Powershell '>' operator, change encoding?
11
2014-07-16 02:45:27
<p>Is there a way to change the default encoding of the > operator in powershell? I'd like it to output as ANSI as UTF-8 for my requirements.txt:</p> <pre><code>pip freeze &gt; requirements.txt </code></pre>
4,514
843,443
2014-07-16 02:48:14
24,771,424
14
2014-07-16 02:48:14
1,545,322
2014-07-16 02:48:14
https://stackoverflow.com/q/24771402
https://stackoverflow.com/a/24771424
<pre><code>pip freeze | Out-File -Encoding UTF8 requirements.txt </code></pre> <p>or you can try</p> <pre><code>pip freeze &gt; iconv -f UTF-8 -t ISO-8859-1 in.txt &gt; out.txt </code></pre> <p>you can read about <a href="http://linux.die.net/man/1/iconv" rel="noreferrer">iconv</a></p>
<pre><code>pip freeze | Out-File -Encoding UTF8 requirements.txt </code></pre> <p>or you can try</p> <pre><code>pip freeze &gt; iconv -f UTF-8 -t ISO-8859-1 in.txt &gt; out.txt </code></pre> <p>you can read about <a href="http://linux.die.net/man/1/iconv" rel="noreferrer">iconv</a></p>
16, 64, 526
powershell, python, windows
<h1>Powershell '>' operator, change encoding?</h1> <p>Is there a way to change the default encoding of the > operator in powershell? I'd like it to output as ANSI as UTF-8 for my requirements.txt:</p> <pre><code>pip freeze &gt; requirements.txt </code></pre>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,697
bash
# Powershell '>' operator, change encoding? Is there a way to change the default encoding of the > operator in powershell? I'd like it to output as ANSI as UTF-8 for my requirements.txt: ``` pip freeze > requirements.txt ```
``` pip freeze | Out-File -Encoding UTF8 requirements.txt ``` or you can try ``` pip freeze > iconv -f UTF-8 -t ISO-8859-1 in.txt > out.txt ``` you can read about [iconv](http://linux.die.net/man/1/iconv)
23379292
How can I grep a keyword which contain underscore?
11
2014-04-30 03:43:00
<p>I am currently searching some keyword something like </p> <p><code>find -type f | xargs -grep -i -w 'weblogic_*'</code> </p> <p>But it show all the keyword match with <code>weblogic</code> instead of <code>weblogic_</code></p>
23,310
3,579,818
2015-05-01 21:11:55
23,379,769
14
2014-04-30 04:36:36
45,375
2014-04-30 06:18:29
https://stackoverflow.com/q/23379292
https://stackoverflow.com/a/23379769
<p><code>grep</code> uses <em>regular expressions</em>, not globs (wildcard expressions).</p> <p>In regular expressions, <code>*</code> is a quantifier that <em>relates to the previous character or expression</em>. Thus, <code>_*</code> is saying: <em>zero or more</em> instances of <code>_</code>, so NO <code>_</code>...
<p><code>grep</code> uses <em>regular expressions</em>, not globs (wildcard expressions).</p> <p>In regular expressions, <code>*</code> is a quantifier that <em>relates to the previous character or expression</em>. Thus, <code>_*</code> is saying: <em>zero or more</em> instances of <code>_</code>, so NO <code>_</code>...
387
bash
<h1>How can I grep a keyword which contain underscore?</h1> <p>I am currently searching some keyword something like </p> <p><code>find -type f | xargs -grep -i -w 'weblogic_*'</code> </p> <p>But it show all the keyword match with <code>weblogic</code> instead of <code>weblogic_</code></p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,698
bash
# How can I grep a keyword which contain underscore? I am currently searching some keyword something like `find -type f | xargs -grep -i -w 'weblogic_*'` But it show all the keyword match with `weblogic` instead of `weblogic_`
`grep` uses *regular expressions*, not globs (wildcard expressions). In regular expressions, `*` is a quantifier that *relates to the previous character or expression*. Thus, `_*` is saying: *zero or more* instances of `_`, so NO `_` will be matched as well. You probably want: ``` 'weblogic_.*' ``` which states tha...
22259418
How does powershell resolve command names?
11
2014-03-07 19:51:45
<p>I'm trying to figure out how powershell resolves names, but I can't seem to find any information.</p> <p>Here is the scenario:</p> <p>There exists an executable:</p> <pre><code>c:\stuff\log.exe </code></pre> <p>The path is set so <code>$env:path = 'c:\stuff\'</code></p> <p>I have a module loaded that includes a...
2,578
190,371
2022-11-27 03:48:10
22,259,706
14
2014-03-07 20:06:46
291,709
2014-03-07 21:03:40
https://stackoverflow.com/q/22259418
https://stackoverflow.com/a/22259706
<p>From <code>help about_Command_Precedence</code>:</p> <pre><code>If you do not specify a path, Windows PowerShell uses the following precedence order when it runs commands: 1. Alias 2. Function 3. Cmdlet 4. Native Windows commands </code></pre> <p>Also,</p> <pre><code>When the session contains ...
<p>From <code>help about_Command_Precedence</code>:</p> <pre><code>If you do not specify a path, Windows PowerShell uses the following precedence order when it runs commands: 1. Alias 2. Function 3. Cmdlet 4. Native Windows commands </code></pre> <p>Also,</p> <pre><code>When the session contains ...
526, 130616
powershell, powershell-core
<h1>How does powershell resolve command names?</h1> <p>I'm trying to figure out how powershell resolves names, but I can't seem to find any information.</p> <p>Here is the scenario:</p> <p>There exists an executable:</p> <pre><code>c:\stuff\log.exe </code></pre> <p>The path is set so <code>$env:path = 'c:\stuff\'</...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,699
bash
# How does powershell resolve command names? I'm trying to figure out how powershell resolves names, but I can't seem to find any information. Here is the scenario: There exists an executable: ``` c:\stuff\log.exe ``` The path is set so `$env:path = 'c:\stuff\'` I have a module loaded that includes a function nam...
From `help about_Command_Precedence`: ``` If you do not specify a path, Windows PowerShell uses the following precedence order when it runs commands: 1. Alias 2. Function 3. Cmdlet 4. Native Windows commands ``` Also, ``` When the session contains items of the same type that have the same name...
22204241
How to mix bash with python
11
2014-03-05 16:59:19
<p>I enjoy using unix commands very much, but I came to the point, where I would find embedded python parts useful. This is my code:</p> <pre><code>#!/bin/bash - echo "hello!"; exec python &lt;&lt;END_OF_PYTHON #!/usr/bin/env python import sys print ("xyzzy") sys.exit(0) END_OF_PYTHON echo "goodbye!"; </code></pr...
8,661
995,372
2022-06-29 08:29:43
22,204,560
14
2014-03-05 17:14:13
1,583,065
2014-03-05 17:14:13
https://stackoverflow.com/q/22204241
https://stackoverflow.com/a/22204560
<p>On the <code>exec python ...</code> line, you're <code>exec()</code>ing the Python interpreter on your <code>PATH</code>, so the <code>python</code> image will replace the <code>bash</code> image, and there is absolutely no hope of the <code>echo "goodbye!"</code> ever being executed. If that's what you want, that's...
<p>On the <code>exec python ...</code> line, you're <code>exec()</code>ing the Python interpreter on your <code>PATH</code>, so the <code>python</code> image will replace the <code>bash</code> image, and there is absolutely no hope of the <code>echo "goodbye!"</code> ever being executed. If that's what you want, that's...
16, 387
bash, python
<h1>How to mix bash with python</h1> <p>I enjoy using unix commands very much, but I came to the point, where I would find embedded python parts useful. This is my code:</p> <pre><code>#!/bin/bash - echo "hello!"; exec python &lt;&lt;END_OF_PYTHON #!/usr/bin/env python import sys print ("xyzzy") sys.exit(0) END_OF...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,700
bash
# How to mix bash with python I enjoy using unix commands very much, but I came to the point, where I would find embedded python parts useful. This is my code: ``` #!/bin/bash - echo "hello!"; exec python <<END_OF_PYTHON #!/usr/bin/env python import sys print ("xyzzy") sys.exit(0) END_OF_PYTHON echo "goodbye!"; ...
On the `exec python ...` line, you're `exec()`ing the Python interpreter on your `PATH`, so the `python` image will replace the `bash` image, and there is absolutely no hope of the `echo "goodbye!"` ever being executed. If that's what you want, that's fine, but otherwise, just omit the exec. The shebang (“#!”) line in...
22197380
Is there a "more" command that can be used in the Git shell in windows?
11
2014-03-05 12:10:53
<p>The git shell has a few useful commands that aren't part of windows usual cmd (<code>ls</code>,<code>git grep</code>).</p> <p>Is there a command like *nix's</p> <pre><code>more filename.ext </code></pre> <p>available in the git shell?</p>
7,765
117,507
2019-10-04 09:34:30
22,197,949
14
2014-03-05 12:34:33
1,059,847
2014-03-05 12:34:33
https://stackoverflow.com/q/22197380
https://stackoverflow.com/a/22197949
<p>I have MSys Git v1.8.5.2. It has <code>less</code> command. <a href="https://superuser.com/questions/310137/less-is-more-is-more-less-im-so-confused">Here</a> is good article about both of them.</p>
<p>I have MSys Git v1.8.5.2. It has <code>less</code> command. <a href="https://superuser.com/questions/310137/less-is-more-is-more-less-im-so-confused">Here</a> is good article about both of them.</p>
119, 11225, 92937
command-line-interface, git, git-shell
<h1>Is there a "more" command that can be used in the Git shell in windows?</h1> <p>The git shell has a few useful commands that aren't part of windows usual cmd (<code>ls</code>,<code>git grep</code>).</p> <p>Is there a command like *nix's</p> <pre><code>more filename.ext </code></pre> <p>available in the git shell...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,701
bash
# Is there a "more" command that can be used in the Git shell in windows? The git shell has a few useful commands that aren't part of windows usual cmd (`ls`,`git grep`). Is there a command like *nix's ``` more filename.ext ``` available in the git shell?
I have MSys Git v1.8.5.2. It has `less` command. [Here](https://superuser.com/questions/310137/less-is-more-is-more-less-im-so-confused) is good article about both of them.
21251714
Bash script countdown timer needs to detect any key to continue
11
2014-01-21 07:22:59
<p>I need to listen for any key press in a countdown timer loop. If any key is pressed then the countdown timer should break out of it's loop. This mostly works except for the enter key just makes the countdown timer go faster.</p> <pre><code>#!/bin/bash for (( i=30; i&gt;0; i--)); do printf "\rStarting script i...
3,337
3,218,087
2014-01-22 05:48:13
21,252,715
14
2014-01-21 08:23:40
1,397,956
2014-01-21 08:30:06
https://stackoverflow.com/q/21251714
https://stackoverflow.com/a/21252715
<p>I think based on the return code of <code>read</code>, there is a work around for this problem. From the <code>man</code> page of <code>read</code>, </p> <pre><code>The return code is zero, unless end-of-file is encountered, read times out, or an invalid file descriptor is supplied as the argument to -u. </code></p...
<p>I think based on the return code of <code>read</code>, there is a work around for this problem. From the <code>man</code> page of <code>read</code>, </p> <pre><code>The return code is zero, unless end-of-file is encountered, read times out, or an invalid file descriptor is supplied as the argument to -u. </code></p...
387
bash
<h1>Bash script countdown timer needs to detect any key to continue</h1> <p>I need to listen for any key press in a countdown timer loop. If any key is pressed then the countdown timer should break out of it's loop. This mostly works except for the enter key just makes the countdown timer go faster.</p> <pre><code>#...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,702
bash
# Bash script countdown timer needs to detect any key to continue I need to listen for any key press in a countdown timer loop. If any key is pressed then the countdown timer should break out of it's loop. This mostly works except for the enter key just makes the countdown timer go faster. ``` #!/bin/bash for (( i=30...
I think based on the return code of `read`, there is a work around for this problem. From the `man` page of `read`, ``` The return code is zero, unless end-of-file is encountered, read times out, or an invalid file descriptor is supplied as the argument to -u. ``` The return code for timeout seems to be `142` [verifi...
20744525
How to access Add-Type defined type in other Add-Type type definition?
11
2013-12-23 13:25:04
<p>How to access a type defined by <code>Add-Type -TypeDefinition "..."</code> in another <code>Add-Type -TypeDefinition "..."</code>?</p> <p>In the following code example, in spite of the same namespace, a compiler cannot find the <code>UserCode</code> type.</p> <pre><code>Add-Type -TypeDefinition @" namespace Sampl...
10,404
1,162,275
2013-12-23 18:58:39
20,749,076
14
2013-12-23 18:23:53
null
2013-12-23 18:58:39
https://stackoverflow.com/q/20744525
https://stackoverflow.com/a/20749076
<p>In order to reference the first .NET assembly from the second .NET assembly, you need to persist the first .NET assembly to disk. Once you've done this, you can reference the first .NET assembly from the second .NET assembly using the <code>-ReferencedAssemblies</code> parameter of the <code>Add-Type</code> cmdlet.<...
<p>In order to reference the first .NET assembly from the second .NET assembly, you need to persist the first .NET assembly to disk. Once you've done this, you can reference the first .NET assembly from the second .NET assembly using the <code>-ReferencedAssemblies</code> parameter of the <code>Add-Type</code> cmdlet.<...
526
powershell
<h1>How to access Add-Type defined type in other Add-Type type definition?</h1> <p>How to access a type defined by <code>Add-Type -TypeDefinition "..."</code> in another <code>Add-Type -TypeDefinition "..."</code>?</p> <p>In the following code example, in spite of the same namespace, a compiler cannot find the <code>U...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,703
bash
# How to access Add-Type defined type in other Add-Type type definition? How to access a type defined by `Add-Type -TypeDefinition "..."` in another `Add-Type -TypeDefinition "..."`? In the following code example, in spite of the same namespace, a compiler cannot find the `UserCode` type. ``` Add-Type -TypeDefinitio...
In order to reference the first .NET assembly from the second .NET assembly, you need to persist the first .NET assembly to disk. Once you've done this, you can reference the first .NET assembly from the second .NET assembly using the `-ReferencedAssemblies` parameter of the `Add-Type` cmdlet. **IMPORTANT**: If you us...
17333982
How do I call out to a command-line program from a gnome shell extension?
11
2013-06-27 03:19:11
<p>I have written a simple shell script to accomplish a common task, and I want to be able to run it whenever a button is clicked. I've used gnome-shell-extension-tool to create the Hello World example already, but now I need to know how to simply have it run an arbitrary command when clicked. There is no input or outp...
4,369
7,161
2017-10-31 15:57:47
17,376,133
14
2013-06-29 02:34:34
7,161
2013-06-29 02:34:34
https://stackoverflow.com/q/17333982
https://stackoverflow.com/a/17376133
<p>After some more creative googling, I've found the solution:</p> <pre><code>const Util = imports.misc.util; Util.spawn(['/path/to/program', 'arg1', 'arg2']) </code></pre>
<p>After some more creative googling, I've found the solution:</p> <pre><code>const Util = imports.misc.util; Util.spawn(['/path/to/program', 'arg1', 'arg2']) </code></pre>
68385, 78339
gnome-shell, gnome-shell-extensions
<h1>How do I call out to a command-line program from a gnome shell extension?</h1> <p>I have written a simple shell script to accomplish a common task, and I want to be able to run it whenever a button is clicked. I've used gnome-shell-extension-tool to create the Hello World example already, but now I need to know how...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,704
bash
# How do I call out to a command-line program from a gnome shell extension? I have written a simple shell script to accomplish a common task, and I want to be able to run it whenever a button is clicked. I've used gnome-shell-extension-tool to create the Hello World example already, but now I need to know how to simpl...
After some more creative googling, I've found the solution: ``` const Util = imports.misc.util; Util.spawn(['/path/to/program', 'arg1', 'arg2']) ```
17199736
linux bash script get user input and store in a array
11
2013-06-19 19:30:32
<p>I want to write a bash script that will get user input and store it in an array. Input: 1 4 6 9 11 17 22</p> <p>I want this to be saved as array.</p>
46,894
2,483,655
2017-02-03 01:38:46
17,199,933
14
2013-06-19 19:41:56
548,225
2013-06-19 19:41:56
https://stackoverflow.com/q/17199736
https://stackoverflow.com/a/17199933
<p>read it like this:</p> <pre><code>read -a arr </code></pre> <h3>Test:</h3> <pre><code>read -a arr &lt;&lt;&lt; "1 4 6 9 11 17 22" </code></pre> <p>print # of elements in array: </p> <pre><code>echo ${#arr[@]} </code></pre> <p>OR loop through the above array</p> <pre><code>for i in ${arr[@]} do echo $i # or...
<p>read it like this:</p> <pre><code>read -a arr </code></pre> <h3>Test:</h3> <pre><code>read -a arr &lt;&lt;&lt; "1 4 6 9 11 17 22" </code></pre> <p>print # of elements in array: </p> <pre><code>echo ${#arr[@]} </code></pre> <p>OR loop through the above array</p> <pre><code>for i in ${arr[@]} do echo $i # or...
58, 387, 390
bash, linux, shell
<h1>linux bash script get user input and store in a array</h1> <p>I want to write a bash script that will get user input and store it in an array. Input: 1 4 6 9 11 17 22</p> <p>I want this to be saved as array.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,705
bash
# linux bash script get user input and store in a array I want to write a bash script that will get user input and store it in an array. Input: 1 4 6 9 11 17 22 I want this to be saved as array.
read it like this: ``` read -a arr ``` ### Test: ``` read -a arr <<< "1 4 6 9 11 17 22" ``` print # of elements in array: ``` echo ${#arr[@]} ``` OR loop through the above array ``` for i in ${arr[@]} do echo $i # or do whatever with individual element of the array done ```
17147301
How do I send .png plot to stdout in gnuplot?
11
2013-06-17 12:18:18
<p>Currently, I do something like the following:</p> <pre><code>set term png set output 'file.png' </code></pre> <p>But hardcoding filename in the script is quite inflexible. Is there some way to tell gnuplot to output image file to stdout, so I will be able to redirect it's output where needed?</p>
3,588
486,057
2013-06-17 19:39:51
17,150,191
14
2013-06-17 14:38:04
1,281,879
2013-06-17 19:39:51
https://stackoverflow.com/q/17147301
https://stackoverflow.com/a/17150191
<p>If you do want to send your .png to stdout, just don't set the output:</p> <pre><code>#!/usr/bin/env gnuplot set term png plot x </code></pre> <p>Then run the script</p> <pre><code>./plot.plt &gt; mypng.png </code></pre> <p>I think the bash wrapper makes more sense for most purposes, but this is potentially usef...
<p>If you do want to send your .png to stdout, just don't set the output:</p> <pre><code>#!/usr/bin/env gnuplot set term png plot x </code></pre> <p>Then run the script</p> <pre><code>./plot.plt &gt; mypng.png </code></pre> <p>I think the bash wrapper makes more sense for most purposes, but this is potentially usef...
387, 5401
bash, gnuplot
<h1>How do I send .png plot to stdout in gnuplot?</h1> <p>Currently, I do something like the following:</p> <pre><code>set term png set output 'file.png' </code></pre> <p>But hardcoding filename in the script is quite inflexible. Is there some way to tell gnuplot to output image file to stdout, so I will be able to r...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,706
bash
# How do I send .png plot to stdout in gnuplot? Currently, I do something like the following: ``` set term png set output 'file.png' ``` But hardcoding filename in the script is quite inflexible. Is there some way to tell gnuplot to output image file to stdout, so I will be able to redirect it's output where needed?
If you do want to send your .png to stdout, just don't set the output: ``` #!/usr/bin/env gnuplot set term png plot x ``` Then run the script ``` ./plot.plt > mypng.png ``` I think the bash wrapper makes more sense for most purposes, but this is potentially useful as well.
14909827
execute binary directly from curl
11
2013-02-16 11:36:10
<p>Is there a bash command to execute a binary-"stream"? There is a nice way to load and run shell scripts directly from the internet.</p> <p>as example:</p> <pre><code>curl http://j.mp/spf13-vim3 -L -o - | sh </code></pre> <p>Is it possible to run binaries without saving the file, chmod etc. ?</p> <p>something lik...
5,372
609,712
2013-02-16 11:46:58
14,909,927
14
2013-02-16 11:46:58
20,520
2013-02-16 11:46:58
https://stackoverflow.com/q/14909827
https://stackoverflow.com/a/14909927
<p>The Unix kernels I know expect binary executable files to be stored on disk. This is required so they can perform seek operations to arbitrary offsets, and also map the file contents into memory. Therefore, directly executing a binary stream from the standard input is not possible.</p> <p>The best you can do is t...
<p>The Unix kernels I know expect binary executable files to be stored on disk. This is required so they can perform seek operations to arbitrary offsets, and also map the file contents into memory. Therefore, directly executing a binary stream from the standard input is not possible.</p> <p>The best you can do is t...
368, 387, 1135, 1554
bash, binary, curl, executable
<h1>execute binary directly from curl</h1> <p>Is there a bash command to execute a binary-"stream"? There is a nice way to load and run shell scripts directly from the internet.</p> <p>as example:</p> <pre><code>curl http://j.mp/spf13-vim3 -L -o - | sh </code></pre> <p>Is it possible to run binaries without saving t...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,707
bash
# execute binary directly from curl Is there a bash command to execute a binary-"stream"? There is a nice way to load and run shell scripts directly from the internet. as example: ``` curl http://j.mp/spf13-vim3 -L -o - | sh ``` Is it possible to run binaries without saving the file, chmod etc. ? something like: ...
The Unix kernels I know expect binary executable files to be stored on disk. This is required so they can perform seek operations to arbitrary offsets, and also map the file contents into memory. Therefore, directly executing a binary stream from the standard input is not possible. The best you can do is to write a sc...
13236566
Extract multiple captured groups from sed to variables
11
2012-11-05 16:46:29
<p>I have the following text</p> <pre><code>abc &lt;THIS&gt; abc &lt;THAT&gt; abc &lt;WHAT&gt; abc </code></pre> <p>where <code>abc</code> is a placeholder for a well defined expression. I'd like to extract the 3 terms in the brackets and save them in 3 separate variables. Is is possible to do that without parsing th...
7,983
1,725,377
2012-11-05 20:27:15
13,236,707
14
2012-11-05 16:56:45
978,917
2012-11-05 16:56:45
https://stackoverflow.com/q/13236566
https://stackoverflow.com/a/13236707
<p>If there are any characters that you know will <em>not</em> appear in <code>THIS</code>, <code>THAT</code>, or <code>WHAT</code>, then you can write something like this:</p> <pre><code>IFS=$'\t' read -r VAR1 VAR2 VAR3 \ &lt; &lt;(sed 's/^abc &lt;\(.*\)&gt; abc &lt;\(.*\)&gt; abc &lt;\(.*\)&gt; abc$/\1\t\2\t\3/'...
<p>If there are any characters that you know will <em>not</em> appear in <code>THIS</code>, <code>THAT</code>, or <code>WHAT</code>, then you can write something like this:</p> <pre><code>IFS=$'\t' read -r VAR1 VAR2 VAR3 \ &lt; &lt;(sed 's/^abc &lt;\(.*\)&gt; abc &lt;\(.*\)&gt; abc &lt;\(.*\)&gt; abc$/\1\t\2\t\3/'...
34, 369, 387, 390, 5282
bash, macos, sed, shell, unix
<h1>Extract multiple captured groups from sed to variables</h1> <p>I have the following text</p> <pre><code>abc &lt;THIS&gt; abc &lt;THAT&gt; abc &lt;WHAT&gt; abc </code></pre> <p>where <code>abc</code> is a placeholder for a well defined expression. I'd like to extract the 3 terms in the brackets and save them in 3 ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,708
bash
# Extract multiple captured groups from sed to variables I have the following text ``` abc <THIS> abc <THAT> abc <WHAT> abc ``` where `abc` is a placeholder for a well defined expression. I'd like to extract the 3 terms in the brackets and save them in 3 separate variables. Is is possible to do that without parsing ...
If there are any characters that you know will *not* appear in `THIS`, `THAT`, or `WHAT`, then you can write something like this: ``` IFS=$'\t' read -r VAR1 VAR2 VAR3 \ < <(sed 's/^abc <\(.*\)> abc <\(.*\)> abc <\(.*\)> abc$/\1\t\2\t\3/' \ <<< "$TEXT" ) ``` telling `sed` to use that separator ...
12631021
How do I maximize memory usage using powershell
11
2012-09-27 22:33:37
<p>I am trying do some testing that requires resources to be under pressure. I was able to find out how maximize CPU Usage using PowerShell. </p> <pre><code>start-job -ScriptBlock{ $result = 1; foreach ($number in 1..2147483647) { $result = $result * $number } } </code></pre> <p>Is there a way I can...
11,441
1,704,777
2017-07-20 05:23:00
12,631,167
14
2012-09-27 22:48:16
1,630,171
2016-01-04 22:12:02
https://stackoverflow.com/q/12631021
https://stackoverflow.com/a/12631167
<p>Try this:</p> <pre><code>$mem_stress = "a" * 200MB </code></pre> <p><strong>Edit:</strong> If cou can't allocate all memory in a single chunk, try allocating multiple chunks in an array:</p> <pre><code>$mem_stress = @() for ($i = 0; $i -lt ###; $i++) { $mem_stress += ("a" * 200MB) } </code></pre> <p>The GC doesn...
<p>Try this:</p> <pre><code>$mem_stress = "a" * 200MB </code></pre> <p><strong>Edit:</strong> If cou can't allocate all memory in a single chunk, try allocating multiple chunks in an array:</p> <pre><code>$mem_stress = @() for ($i = 0; $i -lt ###; $i++) { $mem_stress += ("a" * 200MB) } </code></pre> <p>The GC doesn...
61, 186, 526
memory, powershell, testing
<h1>How do I maximize memory usage using powershell</h1> <p>I am trying do some testing that requires resources to be under pressure. I was able to find out how maximize CPU Usage using PowerShell. </p> <pre><code>start-job -ScriptBlock{ $result = 1; foreach ($number in 1..2147483647) { $result = $result...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,709
bash
# How do I maximize memory usage using powershell I am trying do some testing that requires resources to be under pressure. I was able to find out how maximize CPU Usage using PowerShell. ``` start-job -ScriptBlock{ $result = 1; foreach ($number in 1..2147483647) { $result = $result * $number } } ``...
Try this: ``` $mem_stress = "a" * 200MB ``` **Edit:** If cou can't allocate all memory in a single chunk, try allocating multiple chunks in an array: ``` $mem_stress = @() for ($i = 0; $i -lt ###; $i++) { $mem_stress += ("a" * 200MB) } ``` The GC doesn't seem to interfere with this (results from a quick test in a V...
12005080
subtract the values of two columns using awk or bash
11
2012-08-17 11:41:20
<p>I have some text files as shown below. I would like to subtract the values of column 2 and 4 and need to create a new column to the output.</p> <pre><code>co1 co2 co3 co4 r1 15.2 13.0 21.4 r2 23 15 15.7 r3 14 8 12 </code></pre> <p>desired output</p> <pre><code>co1 co2 co3 co4 ...
40,906
1,606,717
2024-04-08 06:24:35
12,005,168
14
2012-08-17 11:46:45
1,209,279
2012-08-17 15:28:33
https://stackoverflow.com/q/12005080
https://stackoverflow.com/a/12005168
<p>Note: You could put the awk commands all on one line, but this is tidier (plus more transparent and easier to modify if need be). </p> <p>This <code>so.awk</code> script:</p> <pre><code>NR==1{print $0, " diff.\n"} NR&gt;2{printf("%s\t%5.1f\n", $0, $2-$4)} </code></pre> <p>gives:</p> <pre><code>co1 co2 co3 ...
<p>Note: You could put the awk commands all on one line, but this is tidier (plus more transparent and easier to modify if need be). </p> <p>This <code>so.awk</code> script:</p> <pre><code>NR==1{print $0, " diff.\n"} NR&gt;2{printf("%s\t%5.1f\n", $0, $2-$4)} </code></pre> <p>gives:</p> <pre><code>co1 co2 co3 ...
387, 990
awk, bash
<h1>subtract the values of two columns using awk or bash</h1> <p>I have some text files as shown below. I would like to subtract the values of column 2 and 4 and need to create a new column to the output.</p> <pre><code>co1 co2 co3 co4 r1 15.2 13.0 21.4 r2 23 15 15.7 r3 14 8 12 </code></p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,710
bash
# subtract the values of two columns using awk or bash I have some text files as shown below. I would like to subtract the values of column 2 and 4 and need to create a new column to the output. ``` co1 co2 co3 co4 r1 15.2 13.0 21.4 r2 23 15 15.7 r3 14 8 12 ``` desired output ``` co1 co...
Note: You could put the awk commands all on one line, but this is tidier (plus more transparent and easier to modify if need be). This `so.awk` script: ``` NR==1{print $0, " diff.\n"} NR>2{printf("%s\t%5.1f\n", $0, $2-$4)} ``` gives: ``` co1 co2 co3 co4 diff. r1 15.2 13.0 21.4 -6.2 r2 23 15 ...
7657846
Executing a shell script in background with php
11
2011-10-05 07:11:28
<p>I need to execute a shell script. The catch is I want to do this</p> <pre><code>$Command = "nohup cvlc input --sout '#transcode {vcodec=h264,acodec=mp3,samplerate=44100}:std{access=http,mux=ffmpeg{mux=flv},dst=0.0.0.0:8083/".output"}' &amp;"; $str = shell_exec($Command); </code></pre> <p>I dont want it to wait til...
18,578
952,289
2014-01-05 20:05:53
7,658,252
14
2011-10-05 07:50:36
245,552
2011-10-05 07:50:36
https://stackoverflow.com/q/7657846
https://stackoverflow.com/a/7658252
<pre><code>$str = shell_exec($Command.' 2&gt;&amp;1 &gt; out.log'); </code></pre> <p>You need to redirect the output of the command.</p> <blockquote> <p>If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or anothe...
<pre><code>$str = shell_exec($Command.' 2&gt;&amp;1 &gt; out.log'); </code></pre> <p>You need to redirect the output of the command.</p> <blockquote> <p>If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or anothe...
5, 58, 390
linux, php, shell
<h1>Executing a shell script in background with php</h1> <p>I need to execute a shell script. The catch is I want to do this</p> <pre><code>$Command = "nohup cvlc input --sout '#transcode {vcodec=h264,acodec=mp3,samplerate=44100}:std{access=http,mux=ffmpeg{mux=flv},dst=0.0.0.0:8083/".output"}' &amp;"; $str = shell_exe...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,711
bash
# Executing a shell script in background with php I need to execute a shell script. The catch is I want to do this ``` $Command = "nohup cvlc input --sout '#transcode {vcodec=h264,acodec=mp3,samplerate=44100}:std{access=http,mux=ffmpeg{mux=flv},dst=0.0.0.0:8083/".output"}' &"; $str = shell_exec($Command); ``` I dont...
``` $str = shell_exec($Command.' 2>&1 > out.log'); ``` You need to redirect the output of the command. > If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP t...
5442003
GAWK Script - Print filename in BEGIN section
11
2011-03-26 11:28:25
<p>I am writing a gawk script that begins </p> <pre><code>#!/bin/gawk -f BEGIN { print FILENAME } </code></pre> <p>I am calling the file via <code>./script file1.html</code> but the script just returns nothing. Any ideas?</p>
7,365
677,960
2016-04-17 23:21:17
5,442,748
14
2011-03-26 13:52:42
586,352
2011-03-26 13:52:42
https://stackoverflow.com/q/5442003
https://stackoverflow.com/a/5442748
<p>you can use ARGV[1] instead of FILENAME if you really want to use it in BEGIN block</p> <pre><code>awk 'BEGIN{print ARGV[1]}' file </code></pre>
<p>you can use ARGV[1] instead of FILENAME if you really want to use it in BEGIN block</p> <pre><code>awk 'BEGIN{print ARGV[1]}' file </code></pre>
58, 387, 390, 990, 13089
awk, bash, gawk, linux, shell
<h1>GAWK Script - Print filename in BEGIN section</h1> <p>I am writing a gawk script that begins </p> <pre><code>#!/bin/gawk -f BEGIN { print FILENAME } </code></pre> <p>I am calling the file via <code>./script file1.html</code> but the script just returns nothing. Any ideas?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,712
bash
# GAWK Script - Print filename in BEGIN section I am writing a gawk script that begins ``` #!/bin/gawk -f BEGIN { print FILENAME } ``` I am calling the file via `./script file1.html` but the script just returns nothing. Any ideas?
you can use ARGV[1] instead of FILENAME if you really want to use it in BEGIN block ``` awk 'BEGIN{print ARGV[1]}' file ```
4988155
Is there a bash command that can tell the size of a shell variable
11
2011-02-14 01:37:46
<p>Is there a way to find the size(memory used) of shell variable from command line, without using C ?</p>
25,625
494,074
2015-01-29 16:37:45
4,988,164
14
2011-02-14 01:40:06
20,862
2011-02-14 01:40:06
https://stackoverflow.com/q/4988155
https://stackoverflow.com/a/4988164
<p><code>wc</code> can tell you how many characters and bytes are in a variable, and bash itself can tell you how many elements are in an array. If what you're looking for is how large bash's internal structures are for holding a specific variable then I don't believe that's available anywhere.</p> <pre><code>$ foo=42...
<p><code>wc</code> can tell you how many characters and bytes are in a variable, and bash itself can tell you how many elements are in an array. If what you're looking for is how large bash's internal structures are for holding a specific variable then I don't believe that's available anywhere.</p> <pre><code>$ foo=42...
58, 387
bash, linux
<h1>Is there a bash command that can tell the size of a shell variable</h1> <p>Is there a way to find the size(memory used) of shell variable from command line, without using C ?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,713
bash
# Is there a bash command that can tell the size of a shell variable Is there a way to find the size(memory used) of shell variable from command line, without using C ?
`wc` can tell you how many characters and bytes are in a variable, and bash itself can tell you how many elements are in an array. If what you're looking for is how large bash's internal structures are for holding a specific variable then I don't believe that's available anywhere. ``` $ foo=42 $ bar=(1 2 3 4) $ echo -...
4251559
How can I tell if a makefile is being run from an interactive shell?
11
2010-11-23 00:14:52
<p>I have a makefile which runs commands that can take a while. I'd like those commands to be chatty if the build is initiated from an interactive shell but quieter if not (specifically, by cron). Something along the lines of (pseudocode):</p> <pre><code>foo_opts = -a -b -c if (make was invoked from an interactive she...
5,285
396,038
2017-05-23 11:44:19
4,251,643
14
2010-11-23 00:30:32
430,775
2010-11-23 00:57:07
https://stackoverflow.com/q/4251559
https://stackoverflow.com/a/4251643
<p>It isn't strictly determining whether it is invoked from an interactive shell or not, but for a cron job in which the output is redirected to a file, the answer to this question would be the same as for <a href="https://stackoverflow.com/questions/911168/detect-if-shell-script-is-running-through-a-pipe">How to detec...
<p>It isn't strictly determining whether it is invoked from an interactive shell or not, but for a cron job in which the output is redirected to a file, the answer to this question would be the same as for <a href="https://stackoverflow.com/questions/911168/detect-if-shell-script-is-running-through-a-pipe">How to detec...
34, 390, 4301, 13213
gnu-make, makefile, shell, unix
<h1>How can I tell if a makefile is being run from an interactive shell?</h1> <p>I have a makefile which runs commands that can take a while. I'd like those commands to be chatty if the build is initiated from an interactive shell but quieter if not (specifically, by cron). Something along the lines of (pseudocode):</p...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,714
bash
# How can I tell if a makefile is being run from an interactive shell? I have a makefile which runs commands that can take a while. I'd like those commands to be chatty if the build is initiated from an interactive shell but quieter if not (specifically, by cron). Something along the lines of (pseudocode): ``` foo_op...
It isn't strictly determining whether it is invoked from an interactive shell or not, but for a cron job in which the output is redirected to a file, the answer to this question would be the same as for [How to detect if my shell script is running through a pipe?](https://stackoverflow.com/questions/911168/detect-if-sh...
3856630
How to separate words in a "sentence" with spaces?
11
2010-10-04 15:24:42
<h2>Background</h2> <p>Looking to automate creating Domains in JasperServer. Domains are a "view" of data for creating ad hoc reports. The names of the columns must be presented to the user in a human readable fashion.</p> <h2>Problem</h2> <p>There are over 2,000 possible pieces of data from which the organization c...
2,105
59,087
2014-09-08 03:37:54
3,856,952
14
2010-10-04 16:02:36
100,754
2010-10-05 13:12:05
https://stackoverflow.com/q/3856630
https://stackoverflow.com/a/3856952
<p>Sometimes, <a href="http://blog.nu42.com/2010/10/sometimes-brute-force-solution-is.html" rel="noreferrer">bruteforcing</a> is acceptable:</p> <pre><code>#!/usr/bin/perl use strict; use warnings; use File::Slurp; my $dict_file = '/usr/share/dict/words'; my @identifiers = qw( payperiodmatchcode labordistributi...
<p>Sometimes, <a href="http://blog.nu42.com/2010/10/sometimes-brute-force-solution-is.html" rel="noreferrer">bruteforcing</a> is acceptable:</p> <pre><code>#!/usr/bin/perl use strict; use warnings; use File::Slurp; my $dict_file = '/usr/share/dict/words'; my @identifiers = qw( payperiodmatchcode labordistributi...
387, 580, 990, 2370, 87686
awk, bash, nlp, perl, text-segmentation
<h1>How to separate words in a "sentence" with spaces?</h1> <h2>Background</h2> <p>Looking to automate creating Domains in JasperServer. Domains are a "view" of data for creating ad hoc reports. The names of the columns must be presented to the user in a human readable fashion.</p> <h2>Problem</h2> <p>There are over...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,715
bash
# How to separate words in a "sentence" with spaces? ## Background Looking to automate creating Domains in JasperServer. Domains are a "view" of data for creating ad hoc reports. The names of the columns must be presented to the user in a human readable fashion. ## Problem There are over 2,000 possible pieces of da...
Sometimes, [bruteforcing](http://blog.nu42.com/2010/10/sometimes-brute-force-solution-is.html) is acceptable: ``` #!/usr/bin/perl use strict; use warnings; use File::Slurp; my $dict_file = '/usr/share/dict/words'; my @identifiers = qw( payperiodmatchcode labordistributioncodedesc dependentrelationship actio...
3457619
How to get line number with error inside trap in powershell?
11
2010-08-11 11:07:02
<p>I use trap to write errors to file, and want write line number where error ocured.</p> <pre><code>$_.Exception.StackTrace is not answer. </code></pre> <p>Where I can get line number of error? Maybe some predefined variable?</p>
13,117
417,138
2016-03-27 14:46:02
3,457,747
14
2010-08-11 11:25:52
404,854
2010-08-11 11:25:52
https://stackoverflow.com/q/3457619
https://stackoverflow.com/a/3457747
<p>You can retrieve the line number from the <code>InvocationInfo</code> object on <code>$_</code>. For example, the script...</p> <pre><code>"Hello, World!" function foo() { trap [Exception] { $_.InvocationInfo.ScriptLineNumber $_.InvocationInfo.OffsetInLine continue; } [reflection.assembly]::load...
<p>You can retrieve the line number from the <code>InvocationInfo</code> object on <code>$_</code>. For example, the script...</p> <pre><code>"Hello, World!" function foo() { trap [Exception] { $_.InvocationInfo.ScriptLineNumber $_.InvocationInfo.OffsetInLine continue; } [reflection.assembly]::load...
526
powershell
<h1>How to get line number with error inside trap in powershell?</h1> <p>I use trap to write errors to file, and want write line number where error ocured.</p> <pre><code>$_.Exception.StackTrace is not answer. </code></pre> <p>Where I can get line number of error? Maybe some predefined variable?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,716
bash
# How to get line number with error inside trap in powershell? I use trap to write errors to file, and want write line number where error ocured. ``` $_.Exception.StackTrace is not answer. ``` Where I can get line number of error? Maybe some predefined variable?
You can retrieve the line number from the `InvocationInfo` object on `$_`. For example, the script... ``` "Hello, World!" function foo() { trap [Exception] { $_.InvocationInfo.ScriptLineNumber $_.InvocationInfo.OffsetInLine continue; } [reflection.assembly]::loadfrom("C:\") } foo ``` ... generate...
2836271
compare two files and get the output for the same lines
11
2010-05-14 17:35:15
<p>How can I get the following output using linux command by comparing two text files? Thanks.</p> <p>file1:</p> <pre><code>site110 site120 </code></pre> <p>file2(Updated):</p> <pre><code>domain1.com - site110 domain2.com - site111 domain3.com - site112 domain4.com - site113 domain5.com - site120 domain6.com - site...
19,427
214,858
2015-11-12 20:34:52
2,836,340
14
2010-05-14 17:44:45
143,804
2010-05-14 17:44:45
https://stackoverflow.com/q/2836271
https://stackoverflow.com/a/2836340
<p>From the <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?grep" rel="noreferrer">grep manpage</a>:</p> <pre><code> -f FILE, --file=FILE Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing. (-f is specified by POSIX.) ...
<p>From the <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?grep" rel="noreferrer">grep manpage</a>:</p> <pre><code> -f FILE, --file=FILE Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing. (-f is specified by POSIX.) ...
58, 387
bash, linux
<h1>compare two files and get the output for the same lines</h1> <p>How can I get the following output using linux command by comparing two text files? Thanks.</p> <p>file1:</p> <pre><code>site110 site120 </code></pre> <p>file2(Updated):</p> <pre><code>domain1.com - site110 domain2.com - site111 domain3.com - site1...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,717
bash
# compare two files and get the output for the same lines How can I get the following output using linux command by comparing two text files? Thanks. file1: ``` site110 site120 ``` file2(Updated): ``` domain1.com - site110 domain2.com - site111 domain3.com - site112 domain4.com - site113 domain5.com - site120 doma...
From the [grep manpage](http://unixhelp.ed.ac.uk/CGI/man-cgi?grep): ``` -f FILE, --file=FILE Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing. (-f is specified by POSIX.) ``` Therefore: ``` grep -f file1 file2 ...
2084832
How can I create 1000 files that I can use to test a script?
11
2010-01-18 09:00:37
<p>I would like to create 1000+ text files with some text to test a script, how to create this much if text files at a go using shell script or Perl. Please could anyone help me?</p>
14,635
197,937
2021-09-25 04:11:54
2,084,946
14
2010-01-18 09:20:05
131,527
2010-01-18 10:28:34
https://stackoverflow.com/q/2084832
https://stackoverflow.com/a/2084946
<pre><code>for i in {0001..1000} do echo "some text" &gt; "file_${i}.txt" done </code></pre> <p>or if you want to use Python &lt;2.6</p> <pre><code>for x in range(1000): open("file%03d.txt" % x,"w").write("some text") </code></pre>
<pre><code>for i in {0001..1000} do echo "some text" &gt; "file_${i}.txt" done </code></pre> <p>or if you want to use Python &lt;2.6</p> <pre><code>for x in range(1000): open("file%03d.txt" % x,"w").write("some text") </code></pre>
16, 387, 390, 531, 580
bash, perl, python, scripting, shell
<h1>How can I create 1000 files that I can use to test a script?</h1> <p>I would like to create 1000+ text files with some text to test a script, how to create this much if text files at a go using shell script or Perl. Please could anyone help me?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,718
bash
# How can I create 1000 files that I can use to test a script? I would like to create 1000+ text files with some text to test a script, how to create this much if text files at a go using shell script or Perl. Please could anyone help me?
``` for i in {0001..1000} do echo "some text" > "file_${i}.txt" done ``` or if you want to use Python <2.6 ``` for x in range(1000): open("file%03d.txt" % x,"w").write("some text") ```
1356856
How To start/stop IIS 6.0/7.0 remotely using PowerShell Scripts?
11
2009-08-31 10:40:53
<p>I have two servers Server A and Server B. I want to stop server A from Server B remotely using Powershell script.</p>
49,362
154,287
2017-07-02 23:13:09
1,357,351
14
2009-08-31 13:00:18
37,055
2009-08-31 13:00:18
https://stackoverflow.com/q/1356856
https://stackoverflow.com/a/1357351
<p>One of the simplest ways to do this is really with just a command line execution using <a href="http://www.microsoft.com/technet/sysinternals/Utilities/PsExec.html" rel="noreferrer">PsExec</a>. And send over to the machines</p> <p>IISReset /STOP or /START or /RESTART</p> <p>So you'd do something like this</p> <pr...
<p>One of the simplest ways to do this is really with just a command line execution using <a href="http://www.microsoft.com/technet/sysinternals/Utilities/PsExec.html" rel="noreferrer">PsExec</a>. And send over to the machines</p> <p>IISReset /STOP or /START or /RESTART</p> <p>So you'd do something like this</p> <pr...
215, 526, 22632
iis, powershell, remote-control
<h1>How To start/stop IIS 6.0/7.0 remotely using PowerShell Scripts?</h1> <p>I have two servers Server A and Server B. I want to stop server A from Server B remotely using Powershell script.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,719
bash
# How To start/stop IIS 6.0/7.0 remotely using PowerShell Scripts? I have two servers Server A and Server B. I want to stop server A from Server B remotely using Powershell script.
One of the simplest ways to do this is really with just a command line execution using [PsExec](http://www.microsoft.com/technet/sysinternals/Utilities/PsExec.html). And send over to the machines IISReset /STOP or /START or /RESTART So you'd do something like this ``` PsExec \\Server2 -u Administrator -p somePasswor...
68226426
bash pipe vs here-string
10
2021-07-02 13:56:00
<p>I tought these command were equivalent in bash, but they are producing different outputs. Could you help me understand why?</p> <pre><code>$ echo &quot;SEBA&quot; | wc 1 1 5 </code></pre> <pre><code>$ wc &lt;&lt;&lt; &quot;SEBA&quot; 1 1 5 </code></pre> <p>Running on</p> <ul> <li>Ubuntu 20.04.2 LTS...
2,108
5,448,180
2022-01-07 17:29:17
68,227,338
14
2021-07-02 14:57:19
1,491,895
2022-01-07 17:29:17
https://stackoverflow.com/q/68226426
https://stackoverflow.com/a/68227338
<p>When GNU <code>wc</code> gets all its input from files, it uses <code>stat()</code> (or <code>fstat()</code> for <code>stdin</code>) to get the sizes of the all the files in characters. From this it can determine the maximum number digits needed for each output field, and only uses that many digits.</p> <p>When any ...
<p>When GNU <code>wc</code> gets all its input from files, it uses <code>stat()</code> (or <code>fstat()</code> for <code>stdin</code>) to get the sizes of the all the files in characters. From this it can determine the maximum number digits needed for each output field, and only uses that many digits.</p> <p>When any ...
387, 5813
bash, pipe
<h1>bash pipe vs here-string</h1> <p>I tought these command were equivalent in bash, but they are producing different outputs. Could you help me understand why?</p> <pre><code>$ echo &quot;SEBA&quot; | wc 1 1 5 </code></pre> <pre><code>$ wc &lt;&lt;&lt; &quot;SEBA&quot; 1 1 5 </code></pre> <p>Running ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,720
bash
# bash pipe vs here-string I tought these command were equivalent in bash, but they are producing different outputs. Could you help me understand why? ``` $ echo "SEBA" | wc 1 1 5 ``` ``` $ wc <<< "SEBA" 1 1 5 ``` Running on - Ubuntu 20.04.2 LTS - GNU bash, version 5.0.17(1)-release (x86_64-pc-li...
When GNU `wc` gets all its input from files, it uses `stat()` (or `fstat()` for `stdin`) to get the sizes of the all the files in characters. From this it can determine the maximum number digits needed for each output field, and only uses that many digits. When any of the inputs is a pipe, it's not possible to determi...
67098797
Global routes currently cannot be the only page on the stack
10
2021-04-14 20:37:39
<p>Getting the flyout menu to work in Xamarin Forms the way I want it to has been a major pain. I'm trying to get a certain menu item (My Stats) to go to a certain page if the user is logged in, or to a different page if the user is not (The login page). I have attempted two different approaches with no success.</p> <h...
11,675
2,023,740
2023-04-06 10:26:38
67,099,192
14
2021-04-14 21:13:54
5,228,202
2021-04-14 21:22:49
https://stackoverflow.com/q/67098797
https://stackoverflow.com/a/67099192
<p>You can set up a trick using the property <code>FlyoutItemIsVisible</code>, the <code>ShellContent</code> (thus the related page) will be registered in the Shell hierarchy but won't be visible in the flyout, also it will be loaded only when it is needed since we are using <code>ContentTemplate</code>.</p> <p>Assumin...
<p>You can set up a trick using the property <code>FlyoutItemIsVisible</code>, the <code>ShellContent</code> (thus the related page) will be registered in the Shell hierarchy but won't be visible in the flyout, also it will be loaded only when it is needed since we are using <code>ContentTemplate</code>.</p> <p>Assumin...
66, 1117, 43175, 104707, 138516
flyout, navigation, xamarin.forms, xamarin.forms.shell, xaml
<h1>Global routes currently cannot be the only page on the stack</h1> <p>Getting the flyout menu to work in Xamarin Forms the way I want it to has been a major pain. I'm trying to get a certain menu item (My Stats) to go to a certain page if the user is logged in, or to a different page if the user is not (The login pa...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,721
bash
# Global routes currently cannot be the only page on the stack Getting the flyout menu to work in Xamarin Forms the way I want it to has been a major pain. I'm trying to get a certain menu item (My Stats) to go to a certain page if the user is logged in, or to a different page if the user is not (The login page). I ha...
You can set up a trick using the property `FlyoutItemIsVisible`, the `ShellContent` (thus the related page) will be registered in the Shell hierarchy but won't be visible in the flyout, also it will be loaded only when it is needed since we are using `ContentTemplate`. Assuming you are only using the flyout without th...
62883762
PowerShell bind arrow keys to command history search
10
2020-07-13 20:27:18
<p>In bash, I can bind the Up and Down arrow keys to history search with</p> <pre><code>&quot;\e[5~&quot;: history-search-backward &quot;\e[6~&quot;: history-search-forward </code></pre> <p>in <code>~/.inputrc</code>. If at the prompt I type <code>ca</code> and then the Up key, it will bring the next command line in hi...
2,881
2,707,864
2024-02-10 16:26:01
62,891,313
14
2020-07-14 08:45:25
4,303,355
2024-02-10 16:26:01
https://stackoverflow.com/q/62883762
https://stackoverflow.com/a/62891313
<p>Add the following lines to your Powershell profile.</p> <p>Mine is at <code>%HOME%\Documents\WindowsPowerShell\profile.ps1</code>.</p> <pre><code># Reverse Search Set-PSReadLineOption -HistorySearchCursorMovesToEnd Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadlineKeyHandler -Key Do...
<p>Add the following lines to your Powershell profile.</p> <p>Mine is at <code>%HOME%\Documents\WindowsPowerShell\profile.ps1</code>.</p> <pre><code># Reverse Search Set-PSReadLineOption -HistorySearchCursorMovesToEnd Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadlineKeyHandler -Key Do...
526, 816, 10404, 145953
command-history, key-bindings, powershell, search
<h1>PowerShell bind arrow keys to command history search</h1> <p>In bash, I can bind the Up and Down arrow keys to history search with</p> <pre><code>&quot;\e[5~&quot;: history-search-backward &quot;\e[6~&quot;: history-search-forward </code></pre> <p>in <code>~/.inputrc</code>. If at the prompt I type <code>ca</code> ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,722
bash
# PowerShell bind arrow keys to command history search In bash, I can bind the Up and Down arrow keys to history search with ``` "\e[5~": history-search-backward "\e[6~": history-search-forward ``` in `~/.inputrc`. If at the prompt I type `ca` and then the Up key, it will bring the next command line in history that ...
Add the following lines to your Powershell profile. Mine is at `%HOME%\Documents\WindowsPowerShell\profile.ps1`. ``` # Reverse Search Set-PSReadLineOption -HistorySearchCursorMovesToEnd Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearc...
61178950
Can I use splatting to pass arguments to a non-powershell executable?
10
2020-04-12 22:18:09
<p>Can I do something like this?</p> <pre><code>$splatting_table = @{ "-parameter" = "value" "-parameter2" = "value2" } .\external-command.exe @splatting_table </code></pre> <p>as an equivalent for</p> <pre><code>.\external-command.exe -parameter value -parameter2 value2 </code></pre>
1,145
8,025,936
2025-03-05 02:07:10
61,179,008
14
2020-04-12 22:24:27
45,375
2025-03-05 02:07:10
https://stackoverflow.com/q/61178950
https://stackoverflow.com/a/61179008
<p>While it is <em>technically</em> possible to use a <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Hash_Tables" rel="nofollow noreferrer"><em>hashtable</em></a> for <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_S...
<p>While it is <em>technically</em> possible to use a <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Hash_Tables" rel="nofollow noreferrer"><em>hashtable</em></a> for <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_S...
526, 10355, 135238
parameter-passing, parameter-splatting, powershell
<h1>Can I use splatting to pass arguments to a non-powershell executable?</h1> <p>Can I do something like this?</p> <pre><code>$splatting_table = @{ "-parameter" = "value" "-parameter2" = "value2" } .\external-command.exe @splatting_table </code></pre> <p>as an equivalent for</p> <pre><code>.\external-command....
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,723
bash
# Can I use splatting to pass arguments to a non-powershell executable? Can I do something like this? ``` $splatting_table = @{ "-parameter" = "value" "-parameter2" = "value2" } .\external-command.exe @splatting_table ``` as an equivalent for ``` .\external-command.exe -parameter value -parameter2 value2 ```
While it is *technically* possible to use a [*hashtable*](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Hash_Tables) for [splatting](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_Splatting) with *external programs*, it will rarely w...
53161112
Full Listing of Installed Programs using Powershell
10
2018-11-05 19:39:51
<p>We've used the following command found <a href="https://stackoverflow.com/questions/113542/how-can-i-uninstall-an-application-using-powershell">at this link</a> to try and get a complete listing of installed programs in Windows:</p> <pre><code>Get-WmiObject -Class Win32_Product </code></pre> <p>However, this give...
38,196
1,315,841
2023-08-24 16:32:15
53,161,371
14
2018-11-05 20:01:30
509,839
2018-11-05 21:12:11
https://stackoverflow.com/q/53161112
https://stackoverflow.com/a/53161371
<p>The <code>Get-Package</code> cmdlet provides more information than the <code>Win32_Product</code> class. Here are the differences between the two on my Windows 10 system:</p> <pre><code>PS C:\&gt; Get-WmiObject -Class Win32_Product | Where-Object Name -Match TOSHIBA | Format-Table IdentifyingNumber ...
<p>The <code>Get-Package</code> cmdlet provides more information than the <code>Win32_Product</code> class. Here are the differences between the two on my Windows 10 system:</p> <pre><code>PS C:\&gt; Get-WmiObject -Class Win32_Product | Where-Object Name -Match TOSHIBA | Format-Table IdentifyingNumber ...
64, 526
powershell, windows
<h1>Full Listing of Installed Programs using Powershell</h1> <p>We've used the following command found <a href="https://stackoverflow.com/questions/113542/how-can-i-uninstall-an-application-using-powershell">at this link</a> to try and get a complete listing of installed programs in Windows:</p> <pre><code>Get-WmiObje...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,724
bash
# Full Listing of Installed Programs using Powershell We've used the following command found [at this link](https://stackoverflow.com/questions/113542/how-can-i-uninstall-an-application-using-powershell) to try and get a complete listing of installed programs in Windows: ``` Get-WmiObject -Class Win32_Product ``` Ho...
The `Get-Package` cmdlet provides more information than the `Win32_Product` class. Here are the differences between the two on my Windows 10 system: ``` PS C:\> Get-WmiObject -Class Win32_Product | Where-Object Name -Match TOSHIBA | Format-Table IdentifyingNumber Name Vendo...
52875484
Why would I use an ordered hash in PowerShell?
10
2018-10-18 13:44:44
<p>I'm reading a tutorial and learned that PowerShell supports ordered hashes. When would I use that feature?</p> <p>Sample code of what I'm talking about:</p> <pre><code>$hash = [ordered]@{ ID = 1; Shape = "Square"; Color = "Blue"} </code></pre>
4,112
10,448,260
2023-03-20 16:54:45
52,877,825
14
2018-10-18 15:44:23
45,375
2023-03-20 16:54:45
https://stackoverflow.com/q/52875484
https://stackoverflow.com/a/52877825
<p>Let me complement <a href="https://stackoverflow.com/a/52875534/45375">Maximilian Burszley's helpful answer</a> with a broader perspective:</p> <p><strong>tl;dr</strong></p> <ul> <li><p><strong><em>Most of the time</em> you want <code>[ordered] @{ ... }</code></strong> (<a href="https://learn.microsoft.com/en-us/do...
<p>Let me complement <a href="https://stackoverflow.com/a/52875534/45375">Maximilian Burszley's helpful answer</a> with a broader perspective:</p> <p><strong>tl;dr</strong></p> <ul> <li><p><strong><em>Most of the time</em> you want <code>[ordered] @{ ... }</code></strong> (<a href="https://learn.microsoft.com/en-us/do...
526
powershell
<h1>Why would I use an ordered hash in PowerShell?</h1> <p>I'm reading a tutorial and learned that PowerShell supports ordered hashes. When would I use that feature?</p> <p>Sample code of what I'm talking about:</p> <pre><code>$hash = [ordered]@{ ID = 1; Shape = "Square"; Color = "Blue"} </code></pre>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,725
bash
# Why would I use an ordered hash in PowerShell? I'm reading a tutorial and learned that PowerShell supports ordered hashes. When would I use that feature? Sample code of what I'm talking about: ``` $hash = [ordered]@{ ID = 1; Shape = "Square"; Color = "Blue"} ```
Let me complement [Maximilian Burszley's helpful answer](https://stackoverflow.com/a/52875534/45375) with a broader perspective: **tl;dr** - ***Most of the time* you want `[ordered] @{ ... }`** ([`[System.Collections.Specialized.OrderedDictionary]`](https://learn.microsoft.com/en-us/dotnet/api/system.collections.spec...
51755356
What's the difference between echo and return in bash?
10
2018-08-08 20:43:48
<p>I understand you can use echo for printing information on the console. But I've tried using return with integers and it didn't work very well for me.</p> <p>As of</p> <pre><code>function echo_test() { echo 1; } function output_echo() { local result="$(echo_test)"; if [[ ${result} == 1 ]]; then ...
14,798
1,422,160
2018-08-08 22:39:00
51,755,435
14
2018-08-08 20:49:14
14,122
2018-08-08 22:39:00
https://stackoverflow.com/q/51755356
https://stackoverflow.com/a/51755435
<p>You're conflating two separate things: <strong>output</strong> and <strong>exit status</strong>.</p> <p><code>echo</code> generates <em>output</em>. A command substitution like<code>$(...)</code> captures that output, but if you run a command without it, that output will go to the terminal.</p> <p><code>return</co...
<p>You're conflating two separate things: <strong>output</strong> and <strong>exit status</strong>.</p> <p><code>echo</code> generates <em>output</em>. A command substitution like<code>$(...)</code> captures that output, but if you run a command without it, that output will go to the terminal.</p> <p><code>return</co...
387
bash
<h1>What's the difference between echo and return in bash?</h1> <p>I understand you can use echo for printing information on the console. But I've tried using return with integers and it didn't work very well for me.</p> <p>As of</p> <pre><code>function echo_test() { echo 1; } function output_echo() { local ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,726
bash
# What's the difference between echo and return in bash? I understand you can use echo for printing information on the console. But I've tried using return with integers and it didn't work very well for me. As of ``` function echo_test() { echo 1; } function output_echo() { local result="$(echo_test)"; ...
You're conflating two separate things: **output** and **exit status**. `echo` generates *output*. A command substitution like`$(...)` captures that output, but if you run a command without it, that output will go to the terminal. `return` sets *exit status*. This is what's used to determine which branch is taken when...
51622808
PowerShell dot source within a dot sourced file - import classes
10
2018-07-31 22:09:31
<p>My project is structured like this:</p> <pre><code>MyScript.ps1 classes\ Car.ps1 Tesla.ps1 </code></pre> <p>Car.ps1 is the base class of Tesla.ps1. I attempt to define Tesla like this in Tesla.ps1:</p> <pre><code>. "$PSScriptRoot\Car.ps1" class Tesla : Car { } </code></pre> <p>MyScript.ps1 needs to use ...
2,868
985,851
2023-10-25 16:11:25
51,638,481
14
2018-08-01 16:46:59
45,375
2023-10-25 16:11:25
https://stackoverflow.com/q/51622808
https://stackoverflow.com/a/51638481
<p><a href="https://stackoverflow.com/users/4003407/petseral">PetSerAl</a>, as countless times before, has provided the crucial pointers in a terse comment on the question:</p> <p><strong>Due to your use of <em>classes</em>, you must use <em>modules</em> and import them with <a href="https://learn.microsoft.com/en-us/...
<p><a href="https://stackoverflow.com/users/4003407/petseral">PetSerAl</a>, as countless times before, has provided the crucial pointers in a terse comment on the question:</p> <p><strong>Due to your use of <em>classes</em>, you must use <em>modules</em> and import them with <a href="https://learn.microsoft.com/en-us/...
526, 5187, 67488
class, powershell, powershell-module
<h1>PowerShell dot source within a dot sourced file - import classes</h1> <p>My project is structured like this:</p> <pre><code>MyScript.ps1 classes\ Car.ps1 Tesla.ps1 </code></pre> <p>Car.ps1 is the base class of Tesla.ps1. I attempt to define Tesla like this in Tesla.ps1:</p> <pre><code>. "$PSScriptRoot\Ca...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,727
bash
# PowerShell dot source within a dot sourced file - import classes My project is structured like this: ``` MyScript.ps1 classes\ Car.ps1 Tesla.ps1 ``` Car.ps1 is the base class of Tesla.ps1. I attempt to define Tesla like this in Tesla.ps1: ``` . "$PSScriptRoot\Car.ps1" class Tesla : Car { } ``` MyScript....
[PetSerAl](https://stackoverflow.com/users/4003407/petseral), as countless times before, has provided the crucial pointers in a terse comment on the question: **Due to your use of *classes*, you must use *modules* and import them with [`using module`](https://learn.microsoft.com/en-us/powershell/module/microsoft.power...
49700031
Delete consecutive duplicate lines using unix utilities
10
2018-04-06 19:45:10
<p>This sounds simple on its face but is actually somewhat more complex. I would like to use a unix utility to delete consecutive duplicates, leaving the original. But, I would also like to preserve other duplicates that do not occur immediately after the original. For example, if we have the lines:</p> <pre><code>O B...
3,903
6,554,155
2021-10-08 11:38:38
49,700,064
14
2018-04-06 19:48:30
9,164,010
2018-04-06 20:05:25
https://stackoverflow.com/q/49700031
https://stackoverflow.com/a/49700064
<p>You can do:</p> <pre><code>cat file1 | uniq &gt; file2 </code></pre> <p>or more succinctly:</p> <pre><code>uniq file1 file2 </code></pre> <p>assuming <code>file1</code> contains</p> <pre><code>O B O B C D T V O B </code></pre> <p>For more details, see <a href="https://linux.die.net/man/1/uniq" rel="noreferrer"...
<p>You can do:</p> <pre><code>cat file1 | uniq &gt; file2 </code></pre> <p>or more succinctly:</p> <pre><code>uniq file1 file2 </code></pre> <p>assuming <code>file1</code> contains</p> <pre><code>O B O B C D T V O B </code></pre> <p>For more details, see <a href="https://linux.die.net/man/1/uniq" rel="noreferrer"...
34, 387, 8811, 12147
bash, duplicates, unix, utility
<h1>Delete consecutive duplicate lines using unix utilities</h1> <p>This sounds simple on its face but is actually somewhat more complex. I would like to use a unix utility to delete consecutive duplicates, leaving the original. But, I would also like to preserve other duplicates that do not occur immediately after the...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,728
bash
# Delete consecutive duplicate lines using unix utilities This sounds simple on its face but is actually somewhat more complex. I would like to use a unix utility to delete consecutive duplicates, leaving the original. But, I would also like to preserve other duplicates that do not occur immediately after the original...
You can do: ``` cat file1 | uniq > file2 ``` or more succinctly: ``` uniq file1 file2 ``` assuming `file1` contains ``` O B O B C D T V O B ``` For more details, see [man uniq](https://linux.die.net/man/1/uniq). In particular, note that the `uniq` command accepts two arguments with the following syntax: `uniq [OP...
44032838
Are all CMD commands available within powershell?
10
2017-05-17 18:59:02
<p>Similar to other questions, but are ALL CMD commands usable within Powershell? In short, can I use a Powershell window to supplant CMD prompts, and do both CMD work and Powershell work in the same terminal?</p>
8,750
1,716,737
2023-07-22 17:23:31
44,032,920
14
2017-05-17 19:04:21
45,375
2023-07-22 17:23:31
https://stackoverflow.com/q/44032838
https://stackoverflow.com/a/44032920
<p>Those <strong>commands that are <em>built into</em> <code>cmd.exe</code></strong> (e.g., <code>dir</code>, <code>type</code>) are <strong><em>not directly</em> callable</strong> in a PowerShell session, but you can <strong>call them via <code>cmd /c ...</code></strong>; e.g.:</p> <pre class="lang-bash prettyprint-...
<p>Those <strong>commands that are <em>built into</em> <code>cmd.exe</code></strong> (e.g., <code>dir</code>, <code>type</code>) are <strong><em>not directly</em> callable</strong> in a PowerShell session, but you can <strong>call them via <code>cmd /c ...</code></strong>; e.g.:</p> <pre class="lang-bash prettyprint-...
526, 2631
cmd, powershell
<h1>Are all CMD commands available within powershell?</h1> <p>Similar to other questions, but are ALL CMD commands usable within Powershell? In short, can I use a Powershell window to supplant CMD prompts, and do both CMD work and Powershell work in the same terminal?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,729
bash
# Are all CMD commands available within powershell? Similar to other questions, but are ALL CMD commands usable within Powershell? In short, can I use a Powershell window to supplant CMD prompts, and do both CMD work and Powershell work in the same terminal?
Those **commands that are *built into* `cmd.exe`** (e.g., `dir`, `type`) are ***not directly* callable** in a PowerShell session, but you can **call them via `cmd /c ...`**; e.g.: ``` # From PowerShell; calls the cmd.exe-internal `ver` command. cmd /c ver ``` However, you'll find that **most such commands have more p...
37462618
Can't Connect to Mlab
10
2016-05-26 13:42:34
<p>I have a very simple Mlab account and I'm trying to connect via command line with this command:</p> <pre><code>mongo server_name.mlab.com:port/inventory -u &lt;dbuser&gt; -p &lt;dbpassword&gt; </code></pre> <p>but I keep running into this problem:</p> <blockquote> <p>2016-05-26T15:41:18.195+0200 Error: 18 { ok...
14,878
1,419,544
2021-04-26 19:17:45
42,118,327
14
2017-02-08 16:19:04
5,812,306
2017-09-08 19:49:10
https://stackoverflow.com/q/37462618
https://stackoverflow.com/a/42118327
<p>If (like me) you were positive that you were using the correct credentials for the database and for some reason you were still getting the Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } thing, here's what I did.</p> <p>First check your version of mongo.</p> <pre><code>$ mongo --version </code></pre> <p>If...
<p>If (like me) you were positive that you were using the correct credentials for the database and for some reason you were still getting the Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } thing, here's what I did.</p> <p>First check your version of mongo.</p> <pre><code>$ mongo --version </code></pre> <p>If...
390, 30073, 73525
mlab, mongodb, shell
<h1>Can't Connect to Mlab</h1> <p>I have a very simple Mlab account and I'm trying to connect via command line with this command:</p> <pre><code>mongo server_name.mlab.com:port/inventory -u &lt;dbuser&gt; -p &lt;dbpassword&gt; </code></pre> <p>but I keep running into this problem:</p> <blockquote> <p>2016-05-26T1...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,730
bash
# Can't Connect to Mlab I have a very simple Mlab account and I'm trying to connect via command line with this command: ``` mongo server_name.mlab.com:port/inventory -u <dbuser> -p <dbpassword> ``` but I keep running into this problem: > 2016-05-26T15:41:18.195+0200 Error: 18 { ok: 0.0, errmsg: "auth failed", code:...
If (like me) you were positive that you were using the correct credentials for the database and for some reason you were still getting the Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } thing, here's what I did. First check your version of mongo. ``` $ mongo --version ``` If it is less than 3.x.x congratulat...
41043163
xargs sh -c skipping the first argument
10
2016-12-08 15:35:45
<p>I'm trying to write a script that uses find and xargs to archive old files in a large directory. Here is the line:</p> <pre><code>find /tmp/messages/ -mtime +9 -print0 | xargs -x -t -0 -n 1000 sh -c 'tar rPf /tmp/backup.tar "$@" &amp;&amp; rm -f "$@"; sleep 1 &amp;&amp; echo Finished one loop: $(date +"%T")' </code...
9,006
4,746,428
2016-12-08 16:22:02
41,043,285
14
2016-12-08 15:41:11
548,225
2016-12-08 15:41:11
https://stackoverflow.com/q/41043163
https://stackoverflow.com/a/41043285
<p>First argument to <code>sh -c</code> or <code>bash -c</code> is the name of the script i.e. <code>$0</code> which is not printed when you use <code>$@</code>:</p> <p>Examples:</p> <pre><code>echo a b c d e f| xargs -n 3 bash -c 'echo "$0 $@"' a b c d e f </code></pre> <p>To fix this you can pass <code>_</code> as...
<p>First argument to <code>sh -c</code> or <code>bash -c</code> is the name of the script i.e. <code>$0</code> which is not printed when you use <code>$@</code>:</p> <p>Examples:</p> <pre><code>echo a b c d e f| xargs -n 3 bash -c 'echo "$0 $@"' a b c d e f </code></pre> <p>To fix this you can pass <code>_</code> as...
58, 387, 390, 10193, 10326
bash, find, linux, shell, xargs
<h1>xargs sh -c skipping the first argument</h1> <p>I'm trying to write a script that uses find and xargs to archive old files in a large directory. Here is the line:</p> <pre><code>find /tmp/messages/ -mtime +9 -print0 | xargs -x -t -0 -n 1000 sh -c 'tar rPf /tmp/backup.tar "$@" &amp;&amp; rm -f "$@"; sleep 1 &amp;&a...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,731
bash
# xargs sh -c skipping the first argument I'm trying to write a script that uses find and xargs to archive old files in a large directory. Here is the line: ``` find /tmp/messages/ -mtime +9 -print0 | xargs -x -t -0 -n 1000 sh -c 'tar rPf /tmp/backup.tar "$@" && rm -f "$@"; sleep 1 && echo Finished one loop: $(date +...
First argument to `sh -c` or `bash -c` is the name of the script i.e. `$0` which is not printed when you use `$@`: Examples: ``` echo a b c d e f| xargs -n 3 bash -c 'echo "$0 $@"' a b c d e f ``` To fix this you can pass `_` as dummy name of the script and then it should work: ``` echo a b c d e f| xargs -n 3 bash...
40476707
Filter docker-compose output
10
2016-11-07 23:50:47
<p>I have several containers that give many hundreds of lines of output when I do a docker-compose up and load all my services. Is there a way to filter that output easily or better yet, not have those services output to standard out, when doing docker-compose up?</p>
8,167
654,457
2023-07-21 23:51:33
40,477,400
14
2016-11-08 01:13:10
4,155,432
2016-11-08 22:44:49
https://stackoverflow.com/q/40476707
https://stackoverflow.com/a/40477400
<p>Use detached mode when you start your docker compose</p> <pre><code>docker-compose up -d </code></pre> <p>If you want to see the logs of your containers, you can do:</p> <pre><code>docker-compose logs &lt;name of your service that was defined in docker-compose file&gt; </code></pre>
<p>Use detached mode when you start your docker compose</p> <pre><code>docker-compose up -d </code></pre> <p>If you want to see the logs of your containers, you can do:</p> <pre><code>docker-compose logs &lt;name of your service that was defined in docker-compose file&gt; </code></pre>
387, 90304, 110604
bash, docker, docker-compose
<h1>Filter docker-compose output</h1> <p>I have several containers that give many hundreds of lines of output when I do a docker-compose up and load all my services. Is there a way to filter that output easily or better yet, not have those services output to standard out, when doing docker-compose up?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,732
bash
# Filter docker-compose output I have several containers that give many hundreds of lines of output when I do a docker-compose up and load all my services. Is there a way to filter that output easily or better yet, not have those services output to standard out, when doing docker-compose up?
Use detached mode when you start your docker compose ``` docker-compose up -d ``` If you want to see the logs of your containers, you can do: ``` docker-compose logs <name of your service that was defined in docker-compose file> ```
39145550
date: extra operand %d' error
10
2016-08-25 12:38:22
<p>I have a text log file, the format is like the following</p> <pre><code>Thread-28689296: Thu Aug 25 15:18:41 2016 [ info ]: xxxxx xxxxxx xxxxx </code></pre> <p>So I want to run cron job to find some certain error messages in last a few minutes. I wrote the following command </p> <pre><code>awk -vDate=`date +%b %d...
39,502
5,346,154
2016-08-25 12:59:51
39,145,841
14
2016-08-25 12:51:37
1,983,854
2016-08-25 12:59:51
https://stackoverflow.com/q/39145550
https://stackoverflow.com/a/39145841
<p>The problem here is with <code>date</code> itself. Let's see how.</p> <p>You are saying:</p> <pre><code>vDate2=`date --date="2 minutes ago" +%b %d %H:%M:%S %Y` </code></pre> <p>Because you want to use</p> <pre><code>date --date="2 minutes ago" +%b %d %H:%M:%S %Y </code></pre> <p>However, if you try to run it yo...
<p>The problem here is with <code>date</code> itself. Let's see how.</p> <p>You are saying:</p> <pre><code>vDate2=`date --date="2 minutes ago" +%b %d %H:%M:%S %Y` </code></pre> <p>Because you want to use</p> <pre><code>date --date="2 minutes ago" +%b %d %H:%M:%S %Y </code></pre> <p>However, if you try to run it yo...
390, 990, 5002
awk, date, shell
<h1>date: extra operand %d' error</h1> <p>I have a text log file, the format is like the following</p> <pre><code>Thread-28689296: Thu Aug 25 15:18:41 2016 [ info ]: xxxxx xxxxxx xxxxx </code></pre> <p>So I want to run cron job to find some certain error messages in last a few minutes. I wrote the following command <...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,733
bash
# date: extra operand %d' error I have a text log file, the format is like the following ``` Thread-28689296: Thu Aug 25 15:18:41 2016 [ info ]: xxxxx xxxxxx xxxxx ``` So I want to run cron job to find some certain error messages in last a few minutes. I wrote the following command ``` awk -vDate=`date +%b %d %H:%M...
The problem here is with `date` itself. Let's see how. You are saying: ``` vDate2=`date --date="2 minutes ago" +%b %d %H:%M:%S %Y` ``` Because you want to use ``` date --date="2 minutes ago" +%b %d %H:%M:%S %Y ``` However, if you try to run it you'll see that you get the error: > date: extra operand ‘%d’ > Try ...
38831008
Start PowerShell with -NoExit not working
10
2016-08-08 13:51:26
<p>Need to launch several jobs in PowerShell, but they should be in different sessions. So to launch one, one could use:</p> <pre><code>Start-Process powershell -ArgumentList "-command &amp;{Get-Process}","-noexit","-noprofile" </code></pre> <p>But the new window closes as soon as the command finishes. Even though I'...
17,011
5,149,254
2016-08-08 13:54:28
38,831,071
14
2016-08-08 13:54:28
6,666,743
2016-08-08 13:54:28
https://stackoverflow.com/q/38831008
https://stackoverflow.com/a/38831071
<p>While the command parameters are named, position is still critical (see PowerShell.exe /?):</p> <pre><code>Start-Process powershell -ArgumentList "-noexit", "-noprofile", "-command &amp;{Get-Process}" </code></pre>
<p>While the command parameters are named, position is still critical (see PowerShell.exe /?):</p> <pre><code>Start-Process powershell -ArgumentList "-noexit", "-noprofile", "-command &amp;{Get-Process}" </code></pre>
526
powershell
<h1>Start PowerShell with -NoExit not working</h1> <p>Need to launch several jobs in PowerShell, but they should be in different sessions. So to launch one, one could use:</p> <pre><code>Start-Process powershell -ArgumentList "-command &amp;{Get-Process}","-noexit","-noprofile" </code></pre> <p>But the new window clo...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,734
bash
# Start PowerShell with -NoExit not working Need to launch several jobs in PowerShell, but they should be in different sessions. So to launch one, one could use: ``` Start-Process powershell -ArgumentList "-command &{Get-Process}","-noexit","-noprofile" ``` But the new window closes as soon as the command finishes. ...
While the command parameters are named, position is still critical (see PowerShell.exe /?): ``` Start-Process powershell -ArgumentList "-noexit", "-noprofile", "-command &{Get-Process}" ```
36275618
Why is Invoke-WebRequest and Invoke-RestMethod failing and succeeding at the same time?
10
2016-03-29 04:43:42
<p>I wrote a small PowerShell script to send a request to a server and get a simple XML result back.</p> <p><strong>PowerShell Script</strong></p> <pre><code>$xml = "&lt;?xml version='1.0' encoding='utf-8'?&gt;&lt;Search&gt;&lt;ID&gt;278A87E1-1BC2-4E19-82E9-8BBE31D67D20&lt;/ID&gt;&lt;/Search&gt;" $response = Invoke-R...
11,217
1,628,377
2022-12-25 15:15:06
36,368,402
14
2016-04-02 02:08:49
1,628,377
2016-04-02 02:08:49
https://stackoverflow.com/q/36275618
https://stackoverflow.com/a/36368402
<p>I went ahead and looked into the <code>Invoke-WebRequest</code> cmdlet code and found out why it's failing with this particular error.</p> <p>It's failing on a call to <code>System.Globalization.EncodingTable.GetCodePageFromName</code>. The encoding is passed to that function as a parameter and the encoding is retr...
<p>I went ahead and looked into the <code>Invoke-WebRequest</code> cmdlet code and found out why it's failing with this particular error.</p> <p>It's failing on a call to <code>System.Globalization.EncodingTable.GetCodePageFromName</code>. The encoding is passed to that function as a parameter and the encoding is retr...
526
powershell
<h1>Why is Invoke-WebRequest and Invoke-RestMethod failing and succeeding at the same time?</h1> <p>I wrote a small PowerShell script to send a request to a server and get a simple XML result back.</p> <p><strong>PowerShell Script</strong></p> <pre><code>$xml = "&lt;?xml version='1.0' encoding='utf-8'?&gt;&lt;Search&...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,735
bash
# Why is Invoke-WebRequest and Invoke-RestMethod failing and succeeding at the same time? I wrote a small PowerShell script to send a request to a server and get a simple XML result back. **PowerShell Script** ``` $xml = "<?xml version='1.0' encoding='utf-8'?><Search><ID>278A87E1-1BC2-4E19-82E9-8BBE31D67D20</ID></Se...
I went ahead and looked into the `Invoke-WebRequest` cmdlet code and found out why it's failing with this particular error. It's failing on a call to `System.Globalization.EncodingTable.GetCodePageFromName`. The encoding is passed to that function as a parameter and the encoding is retrieved from the the cmdlet throug...
36186394
Saving arguments passed from xargs to bash as a variable for processing
10
2016-03-23 18:49:28
<p>I am trying to run many commands in parallel, and need to do some string manipulation on the input first. How can I make the below example work?</p> <pre><code>find . -mindepth 1 -type d | xargs -n 1 -P 20 -i sh -c "v={}; echo $v" </code></pre> <p>When I use this, <code>$v</code> is null. Why is it not being saved...
20,020
2,370,863
2025-04-24 07:48:13
36,186,910
14
2016-03-23 19:19:31
3,307,686
2016-03-23 19:55:00
https://stackoverflow.com/q/36186394
https://stackoverflow.com/a/36186910
<p>The parent shell is expanding <code>$v</code> <em>before</em> the string gets passed to <code>xargs</code>.</p> <p>Suppose your <code>find</code> command finds a subdirectory named <code>./stuff</code>.</p> <p>First, the parent <code>bash</code> shell (the one you typed the <code>find</code> command into) will exp...
<p>The parent shell is expanding <code>$v</code> <em>before</em> the string gets passed to <code>xargs</code>.</p> <p>Suppose your <code>find</code> command finds a subdirectory named <code>./stuff</code>.</p> <p>First, the parent <code>bash</code> shell (the one you typed the <code>find</code> command into) will exp...
387, 10326
bash, xargs
<h1>Saving arguments passed from xargs to bash as a variable for processing</h1> <p>I am trying to run many commands in parallel, and need to do some string manipulation on the input first. How can I make the below example work?</p> <pre><code>find . -mindepth 1 -type d | xargs -n 1 -P 20 -i sh -c "v={}; echo $v" </co...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,736
bash
# Saving arguments passed from xargs to bash as a variable for processing I am trying to run many commands in parallel, and need to do some string manipulation on the input first. How can I make the below example work? ``` find . -mindepth 1 -type d | xargs -n 1 -P 20 -i sh -c "v={}; echo $v" ``` When I use this, `$...
The parent shell is expanding `$v` *before* the string gets passed to `xargs`. Suppose your `find` command finds a subdirectory named `./stuff`. First, the parent `bash` shell (the one you typed the `find` command into) will expand `$v`, because the string is in double quotes. You currently have no value set for vari...
35491390
PowerShell function will not return DataTable
10
2016-02-18 20:06:15
<p>I've got a PowerShell script on PowerShell v4.0 (Windows 7 x64 SP1) that creates a pretty complex DataTable. I wanted to be able to place that DataTable code anywhere pretty easily, so I decided to wrap it in a simple function, like so:</p> <pre><code>function Get-UserDataTable { $DataTable = New-Object -TypeN...
6,950
696,808
2019-09-03 14:04:02
35,491,517
14
2016-02-18 20:13:25
696,808
2016-02-29 14:57:35
https://stackoverflow.com/q/35491390
https://stackoverflow.com/a/35491517
<p>As the link in PerSerAl's comment suggests, the issue is caused because DataTable isn't an enumerable data type. To force it to be enumerable, you can use the unary comma operator to put it into an array as a single element. Arrays <em>are</em> enumerable.</p> <pre><code>function Get-UserDataTable { $DataTabl...
<p>As the link in PerSerAl's comment suggests, the issue is caused because DataTable isn't an enumerable data type. To force it to be enumerable, you can use the unary comma operator to put it into an array as a single element. Arrays <em>are</em> enumerable.</p> <pre><code>function Get-UserDataTable { $DataTabl...
491, 526
datatable, powershell
<h1>PowerShell function will not return DataTable</h1> <p>I've got a PowerShell script on PowerShell v4.0 (Windows 7 x64 SP1) that creates a pretty complex DataTable. I wanted to be able to place that DataTable code anywhere pretty easily, so I decided to wrap it in a simple function, like so:</p> <pre><code>function...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,737
bash
# PowerShell function will not return DataTable I've got a PowerShell script on PowerShell v4.0 (Windows 7 x64 SP1) that creates a pretty complex DataTable. I wanted to be able to place that DataTable code anywhere pretty easily, so I decided to wrap it in a simple function, like so: ``` function Get-UserDataTable { ...
As the link in PerSerAl's comment suggests, the issue is caused because DataTable isn't an enumerable data type. To force it to be enumerable, you can use the unary comma operator to put it into an array as a single element. Arrays *are* enumerable. ``` function Get-UserDataTable { $DataTable = New-Object -TypeNam...
33751194
Powershell EMail: How to add new line in email Body?
10
2015-11-17 07:17:03
<p>Very new to Powershell. Wrote powershell script which is working perfectly but when it sends mail it does not show new line character in body. Following are configurations:</p> <pre><code>$EmailFrom = "monitoring@mydomainname.no" $EmailTo = "fatherazrael@tcs.com" $Subject = "Disk Space Low: $server" $Body = "Serve...
71,101
1,382,647
2021-10-07 14:57:14
33,751,797
14
2015-11-17 07:58:44
478,656
2015-11-17 07:58:44
https://stackoverflow.com/q/33751194
https://stackoverflow.com/a/33751797
<p>(From my comment)</p> <p>The PowerShell newline indicator is `n (backtick-n), so:</p> <pre><code>$Body = "Server Name: $server, &lt;NEED NEW LINE&gt; Drive: C </code></pre> <p>becomes:</p> <pre><code>$Body = "Server Name: $server, `n Drive: C </code></pre>
<p>(From my comment)</p> <p>The PowerShell newline indicator is `n (backtick-n), so:</p> <pre><code>$Body = "Server Name: $server, &lt;NEED NEW LINE&gt; Drive: C </code></pre> <p>becomes:</p> <pre><code>$Body = "Server Name: $server, `n Drive: C </code></pre>
146, 526, 3705
email, newline, powershell
<h1>Powershell EMail: How to add new line in email Body?</h1> <p>Very new to Powershell. Wrote powershell script which is working perfectly but when it sends mail it does not show new line character in body. Following are configurations:</p> <pre><code>$EmailFrom = "monitoring@mydomainname.no" $EmailTo = "fatherazrael...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,738
bash
# Powershell EMail: How to add new line in email Body? Very new to Powershell. Wrote powershell script which is working perfectly but when it sends mail it does not show new line character in body. Following are configurations: ``` $EmailFrom = "monitoring@mydomainname.no" $EmailTo = "fatherazrael@tcs.com" $Subject =...
(From my comment) The PowerShell newline indicator is `n (backtick-n), so: ``` $Body = "Server Name: $server, <NEED NEW LINE> Drive: C ``` becomes: ``` $Body = "Server Name: $server, `n Drive: C ```
30658145
Unable to lock file using flock with file descriptor
10
2015-06-05 04:01:23
<p>First let me show what works. If I use flock with the file path, it works.</p> <p>Terminal 1:</p> <pre><code>[root@centos ~]# flock -x -n /tmp/foo.txt -c "sleep 100" </code></pre> <p>Terminal 2:</p> <pre><code>[root@centos ~]# flock -x -n /tmp/foo.txt -c "sleep 100" [root@centos ~]# echo $? 1 </code></pre> <p>T...
9,372
1,175,080
2017-08-07 15:56:50
30,707,721
14
2015-06-08 11:16:00
702,361
2017-08-07 15:56:50
https://stackoverflow.com/q/30658145
https://stackoverflow.com/a/30707721
<p>You are using <code>-n</code> which will terminate if the lock cannot be acquired immediately and <code>flock</code> will fail with exit code 1. Therefore after you execute your the code in the first terminal, it sleeps for 100 seconds. Next when you execute the same in another terminal, <code>flock</code> fails and...
<p>You are using <code>-n</code> which will terminate if the lock cannot be acquired immediately and <code>flock</code> will fail with exit code 1. Therefore after you execute your the code in the first terminal, it sleeps for 100 seconds. Next when you execute the same in another terminal, <code>flock</code> fails and...
58, 390, 511, 3227
concurrency, linux, locking, shell
<h1>Unable to lock file using flock with file descriptor</h1> <p>First let me show what works. If I use flock with the file path, it works.</p> <p>Terminal 1:</p> <pre><code>[root@centos ~]# flock -x -n /tmp/foo.txt -c "sleep 100" </code></pre> <p>Terminal 2:</p> <pre><code>[root@centos ~]# flock -x -n /tmp/foo.txt...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,739
bash
# Unable to lock file using flock with file descriptor First let me show what works. If I use flock with the file path, it works. Terminal 1: ``` [root@centos ~]# flock -x -n /tmp/foo.txt -c "sleep 100" ``` Terminal 2: ``` [root@centos ~]# flock -x -n /tmp/foo.txt -c "sleep 100" [root@centos ~]# echo $? 1 ``` The...
You are using `-n` which will terminate if the lock cannot be acquired immediately and `flock` will fail with exit code 1. Therefore after you execute your the code in the first terminal, it sleeps for 100 seconds. Next when you execute the same in another terminal, `flock` fails and returns 1, but because there is a `...
30596880
run sh script in jmeter
10
2015-06-02 13:00:45
<p>For load testing I want to randomize my testvalues before I run the test in jmeter. To do so, I want to use this bash script:</p> <pre><code>#! /bin/bash cat data.dsv | shuf &gt; randomdata.dsv </code></pre> <p>This should be executed in jmeter. I tried using a BeanShell Sampler with this command (I am using this ...
24,205
3,751,933
2015-06-05 09:44:37
30,597,319
14
2015-06-02 13:18:41
2,897,748
2015-06-05 09:44:37
https://stackoverflow.com/q/30596880
https://stackoverflow.com/a/30597319
<p>I would suggest going for <a href="http://jmeter.apache.org/usermanual/component_reference.html#OS_Process_Sampler" rel="noreferrer">OS Process Sampler</a> instead, it should be easier to use, something like:</p> <p><img src="https://i.sstatic.net/C8TgQ.png" alt="OS Process Sampler Example Configuration"></p> <p>I...
<p>I would suggest going for <a href="http://jmeter.apache.org/usermanual/component_reference.html#OS_Process_Sampler" rel="noreferrer">OS Process Sampler</a> instead, it should be easier to use, something like:</p> <p><img src="https://i.sstatic.net/C8TgQ.png" alt="OS Process Sampler Example Configuration"></p> <p>I...
387, 8401
bash, jmeter
<h1>run sh script in jmeter</h1> <p>For load testing I want to randomize my testvalues before I run the test in jmeter. To do so, I want to use this bash script:</p> <pre><code>#! /bin/bash cat data.dsv | shuf &gt; randomdata.dsv </code></pre> <p>This should be executed in jmeter. I tried using a BeanShell Sampler wi...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,740
bash
# run sh script in jmeter For load testing I want to randomize my testvalues before I run the test in jmeter. To do so, I want to use this bash script: ``` #! /bin/bash cat data.dsv | shuf > randomdata.dsv ``` This should be executed in jmeter. I tried using a BeanShell Sampler with this command (I am using this com...
I would suggest going for [OS Process Sampler](http://jmeter.apache.org/usermanual/component_reference.html#OS_Process_Sampler) instead, it should be easier to use, something like: ![OS Process Sampler Example Configuration](https://i.sstatic.net/C8TgQ.png) In regards to Beanshell approach, there is no need to us __B...
29341813
Bash: run an executable file in background
10
2015-03-30 08:44:39
<p>I have an executable file that contains a long loop, so I want to run it in background, how do I do that with bash script in Linux?</p> <p>I know one way is <kbd>Ctrl</kbd> + z, then I type <code>bg</code>, how to simulate these key pressing in bash script?</p>
16,519
4,016,367
2015-03-30 09:13:02
29,341,875
14
2015-03-30 08:47:56
1,929,187
2015-03-30 08:58:09
https://stackoverflow.com/q/29341813
https://stackoverflow.com/a/29341875
<p>Any executable in linux can be run in the background as follows:</p> <pre><code> $ ./yourExecutable.exe&amp; </code></pre> <p>Add the <code>&amp;</code> character at end. (Assuming <code>yourExecutable.exe</code> is in the current working directory)</p> <h2>How to kill it later on?</h2> <pre><code>$ ps -ax | gre...
<p>Any executable in linux can be run in the background as follows:</p> <pre><code> $ ./yourExecutable.exe&amp; </code></pre> <p>Add the <code>&amp;</code> character at end. (Assuming <code>yourExecutable.exe</code> is in the current working directory)</p> <h2>How to kill it later on?</h2> <pre><code>$ ps -ax | gre...
58, 387, 390
bash, linux, shell
<h1>Bash: run an executable file in background</h1> <p>I have an executable file that contains a long loop, so I want to run it in background, how do I do that with bash script in Linux?</p> <p>I know one way is <kbd>Ctrl</kbd> + z, then I type <code>bg</code>, how to simulate these key pressing in bash script?</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,741
bash
# Bash: run an executable file in background I have an executable file that contains a long loop, so I want to run it in background, how do I do that with bash script in Linux? I know one way is `Ctrl` + z, then I type `bg`, how to simulate these key pressing in bash script?
Any executable in linux can be run in the background as follows: ``` $ ./yourExecutable.exe& ``` Add the `&` character at end. (Assuming `yourExecutable.exe` is in the current working directory) ## How to kill it later on? ``` $ ps -ax | grep yourExecutable.exe ``` You will get an output like: ``` 9384 pts/7 ...
26873289
How to check a disk for partitions for use in a script in Linux?
10
2014-11-11 19:51:35
<p>I'm scripting something in Bash for Linux systems. How would I check a disk for partitions in a robust manner?</p> <p>I could use <code>grep</code>, <code>awk</code>, or <code>sed</code> to parse the output from <code>fdisk</code>, <code>sfdisk</code>, etc., but this doesn't seem to be an exact science.</p> <p>I ...
23,376
1,713,534
2025-07-01 00:00:06
26,874,340
14
2014-11-11 20:52:29
1,713,534
2014-11-11 20:52:29
https://stackoverflow.com/q/26873289
https://stackoverflow.com/a/26874340
<p>I think I figured out a reliable way. I accidentally learned some more features of <code>partprobe</code> while reading the man page:</p> <pre><code>-d Don’t update the kernel. -s Show a summary of devices and their partitions. </code></pre> <p>Used together, I can scan a disk for partitions without updat...
<p>I think I figured out a reliable way. I accidentally learned some more features of <code>partprobe</code> while reading the man page:</p> <pre><code>-d Don’t update the kernel. -s Show a summary of devices and their partitions. </code></pre> <p>Used together, I can scan a disk for partitions without updat...
58, 387, 83645
bash, disk-partitioning, linux
<h1>How to check a disk for partitions for use in a script in Linux?</h1> <p>I'm scripting something in Bash for Linux systems. How would I check a disk for partitions in a robust manner?</p> <p>I could use <code>grep</code>, <code>awk</code>, or <code>sed</code> to parse the output from <code>fdisk</code>, <code>sfd...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,742
bash
# How to check a disk for partitions for use in a script in Linux? I'm scripting something in Bash for Linux systems. How would I check a disk for partitions in a robust manner? I could use `grep`, `awk`, or `sed` to parse the output from `fdisk`, `sfdisk`, etc., but this doesn't seem to be an exact science. I could...
I think I figured out a reliable way. I accidentally learned some more features of `partprobe` while reading the man page: ``` -d Don’t update the kernel. -s Show a summary of devices and their partitions. ``` Used together, I can scan a disk for partitions without updating the kernel and get a reliable outpu...
23755274
Only list host in the bash prompt if running remotely?
10
2014-05-20 08:59:17
<p>I'm trying to modify my Bash prompt to my will; this is how <code>$PS1</code> looks at the moment (with colors edited out for clarity):</p> <pre><code>PS1='\u@\h:\w\$ ' </code></pre> <p>Which results in:</p> <pre><code>andreas@tablet-2710p-ubuntu:~$ </code></pre> <p>Can I tweak the prompt so it hides the <code>...
2,679
617,937
2014-05-27 00:25:35
23,879,344
14
2014-05-27 00:25:35
617,937
2014-05-27 00:25:35
https://stackoverflow.com/q/23755274
https://stackoverflow.com/a/23879344
<p>As brought out in <a href="https://unix.stackexchange.com/a/9607/5769"><em>How can I detect if the shell is controlled from SSH?</em></a>, if either of the variables <code>$SSH_CLIENT</code> or <code>$SSH_TTY</code> are set, it means you are connecting through SSH.</p> <p>If you are on a Debian-based system (such a...
<p>As brought out in <a href="https://unix.stackexchange.com/a/9607/5769"><em>How can I detect if the shell is controlled from SSH?</em></a>, if either of the variables <code>$SSH_CLIENT</code> or <code>$SSH_TTY</code> are set, it means you are connecting through SSH.</p> <p>If you are on a Debian-based system (such a...
387, 53034
bash, ps1
<h1>Only list host in the bash prompt if running remotely?</h1> <p>I'm trying to modify my Bash prompt to my will; this is how <code>$PS1</code> looks at the moment (with colors edited out for clarity):</p> <pre><code>PS1='\u@\h:\w\$ ' </code></pre> <p>Which results in:</p> <pre><code>andreas@tablet-2710p-ubuntu:~$ ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,743
bash
# Only list host in the bash prompt if running remotely? I'm trying to modify my Bash prompt to my will; this is how `$PS1` looks at the moment (with colors edited out for clarity): ``` PS1='\u@\h:\w\$ ' ``` Which results in: ``` andreas@tablet-2710p-ubuntu:~$ ``` Can I tweak the prompt so it hides the `@tablet-27...
As brought out in [*How can I detect if the shell is controlled from SSH?*](https://unix.stackexchange.com/a/9607/5769), if either of the variables `$SSH_CLIENT` or `$SSH_TTY` are set, it means you are connecting through SSH. If you are on a Debian-based system (such as Ubuntu) you can edit your `.bashrc` to something...
23322739
How to execute complex linux commands in Qt?
10
2014-04-27 11:21:23
<p>I want to restart the computer by running a command in linux using <code>QProcess</code>. I have hard-coded my root password in my application.</p> <p>When i run the following in a terminal it works perfect:</p> <pre><code>echo myPass | sudo -S shutdown -r now </code></pre> <p>When i put the command in a shell s...
31,852
3,049,264
2025-03-09 11:32:15
23,322,860
14
2014-04-27 11:32:57
2,682,142
2025-03-09 11:32:15
https://stackoverflow.com/q/23322739
https://stackoverflow.com/a/23322860
<p>The key methods that exist for this purpose established in <code>QProcess</code>:</p> <blockquote> <p><a href="https://doc.qt.io/qt-5/qprocess.html#setProcessChannelMode" rel="nofollow noreferrer">void QProcess::setProcessChannelMode(ProcessChannelMode mode)</a></p> </blockquote> <p>and</p> <blockquote> <p><a href="...
<p>The key methods that exist for this purpose established in <code>QProcess</code>:</p> <blockquote> <p><a href="https://doc.qt.io/qt-5/qprocess.html#setProcessChannelMode" rel="nofollow noreferrer">void QProcess::setProcessChannelMode(ProcessChannelMode mode)</a></p> </blockquote> <p>and</p> <blockquote> <p><a href="...
10, 58, 390, 1158, 20225
c++, linux, qprocess, qt, shell
<h1>How to execute complex linux commands in Qt?</h1> <p>I want to restart the computer by running a command in linux using <code>QProcess</code>. I have hard-coded my root password in my application.</p> <p>When i run the following in a terminal it works perfect:</p> <pre><code>echo myPass | sudo -S shutdown -r now ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,744
bash
# How to execute complex linux commands in Qt? I want to restart the computer by running a command in linux using `QProcess`. I have hard-coded my root password in my application. When i run the following in a terminal it works perfect: ``` echo myPass | sudo -S shutdown -r now ``` When i put the command in a shell...
The key methods that exist for this purpose established in `QProcess`: > [void QProcess::setProcessChannelMode(ProcessChannelMode mode)](https://doc.qt.io/qt-5/qprocess.html#setProcessChannelMode) and > [void QProcess::setStandardOutputProcess(QProcess * destination)](https://doc.qt.io/qt-5/qprocess.html#setStandard...
22612627
Print terminal alias command as well as executing it
10
2014-03-24 14:45:36
<p>As a terminal noob, I've created aliases for pretty much everything I do. The problem is that I've started forgetting those few commands that I do know because of it. On top of that, I sometimes need to edit a variable in the previous command.</p> <p>So what I'd like is if when I use an alias, the first line printe...
4,206
1,720,014
2022-02-23 01:10:07
22,612,932
14
2014-03-24 14:58:28
1,983,854
2014-03-24 14:58:28
https://stackoverflow.com/q/22612627
https://stackoverflow.com/a/22612932
<p>You can always use:</p> <ul> <li><code>alias</code> to list all your aliases, or</li> <li><code>alias name</code> to show the specification of the alias <code>name</code>.</li> </ul> <p>So in fact you can define your alias as</p> <pre><code>alias myalias="alias myalias; &lt;do stuff&gt;" </code></pre> <p>I also ...
<p>You can always use:</p> <ul> <li><code>alias</code> to list all your aliases, or</li> <li><code>alias name</code> to show the specification of the alias <code>name</code>.</li> </ul> <p>So in fact you can define your alias as</p> <pre><code>alias myalias="alias myalias; &lt;do stuff&gt;" </code></pre> <p>I also ...
387, 391
bash, terminal
<h1>Print terminal alias command as well as executing it</h1> <p>As a terminal noob, I've created aliases for pretty much everything I do. The problem is that I've started forgetting those few commands that I do know because of it. On top of that, I sometimes need to edit a variable in the previous command.</p> <p>So ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,745
bash
# Print terminal alias command as well as executing it As a terminal noob, I've created aliases for pretty much everything I do. The problem is that I've started forgetting those few commands that I do know because of it. On top of that, I sometimes need to edit a variable in the previous command. So what I'd like is...
You can always use: - `alias` to list all your aliases, or - `alias name` to show the specification of the alias `name`. So in fact you can define your alias as ``` alias myalias="alias myalias; <do stuff>" ``` I also think that [chepner's answer](https://stackoverflow.com/a/22612852/1983854) with `Alt`-`Control`-`...
20248009
Execute sudo command on Linux from plink.exe on Windows
10
2013-11-27 16:35:09
<p>If I execute the plink command</p> <pre><code>plink user@192.168.1.12 sudo nano /etc/hosts </code></pre> <p>Upon typing the password when prompted, I am getting</p> <blockquote> <p>sudo: no tty present and no askpass program specified</p> <p>Sorry, try again.</p> <p>sudo: no tty present and no askpass program spe...
33,130
1,862,493
2021-04-07 06:21:15
22,099,346
14
2014-02-28 15:33:41
2,948,547
2016-02-16 06:45:02
https://stackoverflow.com/q/20248009
https://stackoverflow.com/a/22099346
<p>i know that the question is old but this can help</p> <p>you can execute plink (putty tools)</p> <p><strong>plink -v -ssh -m "path/to/commands.txt" -l usertologin -pw PASSWORDSERVER</strong></p> <p>commands.txt:</p> <blockquote> <p><code>echo -e "PASSWORD\n" | sudo -S cat /etc/passwd</code></p> </blockquote> ...
<p>i know that the question is old but this can help</p> <p>you can execute plink (putty tools)</p> <p><strong>plink -v -ssh -m "path/to/commands.txt" -l usertologin -pw PASSWORDSERVER</strong></p> <p>commands.txt:</p> <blockquote> <p><code>echo -e "PASSWORD\n" | sudo -S cat /etc/passwd</code></p> </blockquote> ...
58, 64, 387, 549, 1768
bash, linux, putty, ubuntu, windows
<h1>Execute sudo command on Linux from plink.exe on Windows</h1> <p>If I execute the plink command</p> <pre><code>plink user@192.168.1.12 sudo nano /etc/hosts </code></pre> <p>Upon typing the password when prompted, I am getting</p> <blockquote> <p>sudo: no tty present and no askpass program specified</p> <p>Sorry, ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,746
bash
# Execute sudo command on Linux from plink.exe on Windows If I execute the plink command ``` plink user@192.168.1.12 sudo nano /etc/hosts ``` Upon typing the password when prompted, I am getting > sudo: no tty present and no askpass program specified > > Sorry, try again. > > sudo: no tty present and no askpass ...
i know that the question is old but this can help you can execute plink (putty tools) **plink -v -ssh -m "path/to/commands.txt" -l usertologin -pw PASSWORDSERVER** commands.txt: > `echo -e "PASSWORD\n" | sudo -S cat /etc/passwd` sudo -S is to receive the password from stdin and with the echo -e "password\n" is to ...
21374118
Size of the sorted file is double than original file in powershell
10
2014-01-27 06:11:14
<p>I have a powershell script, that reads file content, sorts it and writes output to new file. Following is the script: </p> <p>get-content $inputFile | sort > $sortedFile</p> <p>The output in file is sorted properly, but the output file ($sortedFile) is double larger than input file ($inputFile). Note: There are no...
2,558
2,745,525
2014-01-27 18:32:50
21,374,176
14
2014-01-27 06:15:39
52,598
2014-01-27 18:32:50
https://stackoverflow.com/q/21374118
https://stackoverflow.com/a/21374176
<p>Most likely the input file is <code>ascii</code> encoding while the default output using redirection is <code>unicode</code> encoding.</p> <p>Instead of using <code>&gt;</code> as redirection you can use <a href="http://technet.microsoft.com/en-us/library/hh849882.aspx" rel="noreferrer">out-file</a> and specify an ...
<p>Most likely the input file is <code>ascii</code> encoding while the default output using redirection is <code>unicode</code> encoding.</p> <p>Instead of using <code>&gt;</code> as redirection you can use <a href="http://technet.microsoft.com/en-us/library/hh849882.aspx" rel="noreferrer">out-file</a> and specify an ...
134, 526, 24067, 24068, 73157
powershell, powershell-1.0, powershell-2.0, powershell-3.0, sorting
<h1>Size of the sorted file is double than original file in powershell</h1> <p>I have a powershell script, that reads file content, sorts it and writes output to new file. Following is the script: </p> <p>get-content $inputFile | sort > $sortedFile</p> <p>The output in file is sorted properly, but the output file ($s...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,747
bash
# Size of the sorted file is double than original file in powershell I have a powershell script, that reads file content, sorts it and writes output to new file. Following is the script: get-content $inputFile | sort > $sortedFile The output in file is sorted properly, but the output file ($sortedFile) is double lar...
Most likely the input file is `ascii` encoding while the default output using redirection is `unicode` encoding. Instead of using `>` as redirection you can use [out-file](http://technet.microsoft.com/en-us/library/hh849882.aspx) and specify an encoding. `get-content $inputFile | sort | out-file -encoding ASCII`
21264112
How to call PowerShell cmdlets from C# in Visual Studio
10
2014-01-21 16:44:30
<p>I'm creating a PowerShell cmdlets from Visual Studio and I can't find out how to call cmdlets from within my C# file, or if this is even possible? I have no trouble running my cmdlets one by one, but I want to set up a cmdlet to run multiple cmdlets in a sequel. </p>
9,482
1,052,636
2022-12-28 04:40:28
21,264,331
14
2014-01-21 16:54:25
770,270
2014-01-21 18:11:04
https://stackoverflow.com/q/21264112
https://stackoverflow.com/a/21264331
<p>Yes, you can call cmdlets from your C# code.</p> <p>You'll need these two namespaces:</p> <pre><code>using System.Management.Automation; using System.Management.Automation.Runspaces; </code></pre> <p>Open a runspace:</p> <pre><code>Runspace runSpace = RunspaceFactory.CreateRunspace(); runSpace.Open(); </code></p...
<p>Yes, you can call cmdlets from your C# code.</p> <p>You'll need these two namespaces:</p> <pre><code>using System.Management.Automation; using System.Management.Automation.Runspaces; </code></pre> <p>Open a runspace:</p> <pre><code>Runspace runSpace = RunspaceFactory.CreateRunspace(); runSpace.Open(); </code></p...
9, 526, 80825, 153947
c#, powershell, powershell-cmdlet, visual-studio-2012
<h1>How to call PowerShell cmdlets from C# in Visual Studio</h1> <p>I'm creating a PowerShell cmdlets from Visual Studio and I can't find out how to call cmdlets from within my C# file, or if this is even possible? I have no trouble running my cmdlets one by one, but I want to set up a cmdlet to run multiple cmdlets in...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,748
bash
# How to call PowerShell cmdlets from C# in Visual Studio I'm creating a PowerShell cmdlets from Visual Studio and I can't find out how to call cmdlets from within my C# file, or if this is even possible? I have no trouble running my cmdlets one by one, but I want to set up a cmdlet to run multiple cmdlets in a sequel...
Yes, you can call cmdlets from your C# code. You'll need these two namespaces: ``` using System.Management.Automation; using System.Management.Automation.Runspaces; ``` Open a runspace: ``` Runspace runSpace = RunspaceFactory.CreateRunspace(); runSpace.Open(); ``` Create a pipeline: ``` Pipeline pipeline = runSpa...
19682876
Start lein repl with commands from the terminal
10
2013-10-30 12:57:13
<p>I would like to write a shell script to start a lein repl and then provide some commands while still keeping the repl running.</p> <p>For example I might want to do the equivalent of:</p> <pre><code>lein repl (dev) (setup) </code></pre> <p>I can pipe to the repl by <code>echo "(dev)\n(setup)" | lein repl</code> b...
1,967
2,936,410
2013-10-30 13:35:23
19,683,763
14
2013-10-30 13:35:23
1,916,789
2013-10-30 13:35:23
https://stackoverflow.com/q/19682876
https://stackoverflow.com/a/19683763
<pre><code>(echo "(println :hello)"; cat &lt;&amp;0) | lein repl </code></pre> <p>This prints the command - letting the REPL process it -, then "switches back" to stdin for input. You might have to interrupt the <code>cat</code> call after leaving the REPL, though.</p>
<pre><code>(echo "(println :hello)"; cat &lt;&amp;0) | lein repl </code></pre> <p>This prints the command - letting the REPL process it -, then "switches back" to stdin for input. You might have to interrupt the <code>cat</code> call after leaving the REPL, though.</p>
390, 6525, 44091
clojure, leiningen, shell
<h1>Start lein repl with commands from the terminal</h1> <p>I would like to write a shell script to start a lein repl and then provide some commands while still keeping the repl running.</p> <p>For example I might want to do the equivalent of:</p> <pre><code>lein repl (dev) (setup) </code></pre> <p>I can pipe to the...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,749
bash
# Start lein repl with commands from the terminal I would like to write a shell script to start a lein repl and then provide some commands while still keeping the repl running. For example I might want to do the equivalent of: ``` lein repl (dev) (setup) ``` I can pipe to the repl by `echo "(dev)\n(setup)" | lein r...
``` (echo "(println :hello)"; cat <&0) | lein repl ``` This prints the command - letting the REPL process it -, then "switches back" to stdin for input. You might have to interrupt the `cat` call after leaving the REPL, though.
19513174
What's the difference between ${varname} and $varname in a shell scripts
10
2013-10-22 08:48:58
<p>I have a simple question but I wonder what is the difference between <code>${varname}</code> and <code>$varname</code> ?</p> <p>I use both but I don't see any difference which could tell me when to use one or the other.</p>
6,425
1,393,510
2014-04-25 05:39:44
19,513,456
14
2013-10-22 09:03:01
2,235,132
2014-04-25 05:39:44
https://stackoverflow.com/q/19513174
https://stackoverflow.com/a/19513456
<p>Using <code>{}</code> in variable names helps get rid of ambiguity while performing variable expansion.</p> <p>Consider two variables <code>var</code> and <code>varname</code>. Lets see you wanted to append the string <code>name</code> to the variable <code>var</code>. You can't say <code>$varname</code> because ...
<p>Using <code>{}</code> in variable names helps get rid of ambiguity while performing variable expansion.</p> <p>Consider two variables <code>var</code> and <code>varname</code>. Lets see you wanted to append the string <code>name</code> to the variable <code>var</code>. You can't say <code>$varname</code> because ...
34, 390
shell, unix
<h1>What's the difference between ${varname} and $varname in a shell scripts</h1> <p>I have a simple question but I wonder what is the difference between <code>${varname}</code> and <code>$varname</code> ?</p> <p>I use both but I don't see any difference which could tell me when to use one or the other.</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,750
bash
# What's the difference between ${varname} and $varname in a shell scripts I have a simple question but I wonder what is the difference between `${varname}` and `$varname` ? I use both but I don't see any difference which could tell me when to use one or the other.
Using `{}` in variable names helps get rid of ambiguity while performing variable expansion. Consider two variables `var` and `varname`. Lets see you wanted to append the string `name` to the variable `var`. You can't say `$varname` because that would result in the expansion of the variable `varname`. However, saying ...
17717728
How to broadcast intent with extras through ADB shell?
10
2013-07-18 07:53:11
<p>I am trying to send the <code>BATTERY_CHANGED</code> intent through the ADB shell. So far I only managed to send the intent with no information:</p> <pre><code>am broadcast -a android.intent.action.BATTERY_CHANGED </code></pre> <p>I created an app witch listens for this intent and here is what the system sends eve...
24,178
2,594,202
2020-03-18 15:55:16
17,722,752
14
2013-07-18 11:54:02
1,778,421
2020-03-18 15:55:16
https://stackoverflow.com/q/17717728
https://stackoverflow.com/a/17722752
<p>The <code>&lt;INTENT&gt;</code> parameter format is the same for all <code>am</code> subcommands like <code>start</code>, <code>startservice</code> and <code>broadcast</code>.</p> <p>It could be passed as a combination of separate parameters like <code>-a &lt;ACTION&gt;</code>, <code>-c &lt;CATEGORY&gt;</code>, <co...
<p>The <code>&lt;INTENT&gt;</code> parameter format is the same for all <code>am</code> subcommands like <code>start</code>, <code>startservice</code> and <code>broadcast</code>.</p> <p>It could be passed as a combination of separate parameters like <code>-a &lt;ACTION&gt;</code>, <code>-c &lt;CATEGORY&gt;</code>, <co...
390, 1386, 7652, 22975, 47962
adb, android, android-intent, broadcast, shell
<h1>How to broadcast intent with extras through ADB shell?</h1> <p>I am trying to send the <code>BATTERY_CHANGED</code> intent through the ADB shell. So far I only managed to send the intent with no information:</p> <pre><code>am broadcast -a android.intent.action.BATTERY_CHANGED </code></pre> <p>I created an app wit...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,751
bash
# How to broadcast intent with extras through ADB shell? I am trying to send the `BATTERY_CHANGED` intent through the ADB shell. So far I only managed to send the intent with no information: ``` am broadcast -a android.intent.action.BATTERY_CHANGED ``` I created an app witch listens for this intent and here is what ...
The `<INTENT>` parameter format is the same for all `am` subcommands like `start`, `startservice` and `broadcast`. It could be passed as a combination of separate parameters like `-a <ACTION>`, `-c <CATEGORY>`, `-n <COMPONENT>` and different `-e <EXTRA>` for different types of extras or as a single `URI` formatted str...
17370164
Check if a command exists in Bash (including superusers)
10
2013-06-28 17:12:01
<p>I'd like to check whether a program is installed on an UNIX system.</p> <p>I could use commands like:</p> <ul> <li><code>command -v</code>,</li> <li><code>hash</code>,</li> <li><code>type</code>,</li> <li><code>which</code>...</li> </ul> <p>...and all of them are already mentioned <a href="https://stackoverflow.c...
5,517
2,016,221
2013-06-30 18:13:00
17,370,165
14
2013-06-28 17:12:01
2,016,221
2013-06-30 18:13:00
https://stackoverflow.com/q/17370164
https://stackoverflow.com/a/17370165
<h1>Source of the problem</h1> <p>The reason the commands you tried do not work is that they only look for executables in <code>$PATH</code> variable. First, let's test our hypothesis.</p> <pre><code>dummy:~$ mkdir test dummy:~$ cd test dummy:~/test$ echo '#!/bin/sh' &gt;test.sh dummy:~/test$ chmod +x test.sh dummy:~...
<h1>Source of the problem</h1> <p>The reason the commands you tried do not work is that they only look for executables in <code>$PATH</code> variable. First, let's test our hypothesis.</p> <pre><code>dummy:~$ mkdir test dummy:~$ cd test dummy:~/test$ echo '#!/bin/sh' &gt;test.sh dummy:~/test$ chmod +x test.sh dummy:~...
387, 390
bash, shell
<h1>Check if a command exists in Bash (including superusers)</h1> <p>I'd like to check whether a program is installed on an UNIX system.</p> <p>I could use commands like:</p> <ul> <li><code>command -v</code>,</li> <li><code>hash</code>,</li> <li><code>type</code>,</li> <li><code>which</code>...</li> </ul> <p>...and ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,752
bash
# Check if a command exists in Bash (including superusers) I'd like to check whether a program is installed on an UNIX system. I could use commands like: - `command -v`, - `hash`, - `type`, - `which`... ...and all of them are already mentioned [in this answer](https://stackoverflow.com/questions/592620/check-if-a-p...
# Source of the problem The reason the commands you tried do not work is that they only look for executables in `$PATH` variable. First, let's test our hypothesis. ``` dummy:~$ mkdir test dummy:~$ cd test dummy:~/test$ echo '#!/bin/sh' >test.sh dummy:~/test$ chmod +x test.sh dummy:~/test$ cd dummy:~$ command -v test....
17199089
Find out how many SSH connections currently exist
10
2013-06-19 18:53:59
<p>I'm using a simple shell script on my Linux server which checks if an rsync job is running or if any client accesses some directories from the server via Samba. If this is the case then nothing happens, but if are there no jobs and Samba isn't used than the server goes into hibernation.</p> <p>Is there any simple co...
25,744
2,502,527
2022-06-18 21:14:24
17,199,148
14
2013-06-19 18:58:07
782,822
2022-06-18 21:11:45
https://stackoverflow.com/q/17199089
https://stackoverflow.com/a/17199148
<p>Scan the process list for <code>sshd: </code>.</p> <p>Established connections look something like this: <code>sshd: &lt;username&gt;…</code></p> <pre><code>ps -A x | grep [s]shd </code></pre> <p>should work for you.</p>
<p>Scan the process list for <code>sshd: </code>.</p> <p>Established connections look something like this: <code>sshd: &lt;username&gt;…</code></p> <pre><code>ps -A x | grep [s]shd </code></pre> <p>should work for you.</p>
58, 387, 390
bash, linux, shell
<h1>Find out how many SSH connections currently exist</h1> <p>I'm using a simple shell script on my Linux server which checks if an rsync job is running or if any client accesses some directories from the server via Samba. If this is the case then nothing happens, but if are there no jobs and Samba isn't used than the ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,753
bash
# Find out how many SSH connections currently exist I'm using a simple shell script on my Linux server which checks if an rsync job is running or if any client accesses some directories from the server via Samba. If this is the case then nothing happens, but if are there no jobs and Samba isn't used than the server go...
Scan the process list for `sshd:` . Established connections look something like this: `sshd: <username>…` ``` ps -A x | grep [s]shd ``` should work for you.
17102354
Calling makefiles from Shell Script
10
2013-06-14 06:26:41
<p>I am new to shell script. I want to call a list of make files from Shell script in a particular order. For each makefile I want to get the result (make is success or failure). If any error I want to stop the script execution. If it is success I have to run the next makefile. </p>
25,199
967,018
2016-12-14 09:11:03
17,102,826
14
2013-06-14 07:00:28
874,188
2015-01-28 09:38:33
https://stackoverflow.com/q/17102354
https://stackoverflow.com/a/17102826
<p>A common idiom is to create a shell script with <code>set -e</code>; this will cause the script to exit on the first error.</p> <pre><code>#!/bin/sh set -e make -f Makefile1 make -f Makefile2 : </code></pre> <p>If you need more control over the script overall, maybe remove <code>set -e</code> and instead explicitl...
<p>A common idiom is to create a shell script with <code>set -e</code>; this will cause the script to exit on the first error.</p> <pre><code>#!/bin/sh set -e make -f Makefile1 make -f Makefile2 : </code></pre> <p>If you need more control over the script overall, maybe remove <code>set -e</code> and instead explicitl...
58, 390, 4301
linux, makefile, shell
<h1>Calling makefiles from Shell Script</h1> <p>I am new to shell script. I want to call a list of make files from Shell script in a particular order. For each makefile I want to get the result (make is success or failure). If any error I want to stop the script execution. If it is success I have to run the next makef...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,754
bash
# Calling makefiles from Shell Script I am new to shell script. I want to call a list of make files from Shell script in a particular order. For each makefile I want to get the result (make is success or failure). If any error I want to stop the script execution. If it is success I have to run the next makefile.
A common idiom is to create a shell script with `set -e`; this will cause the script to exit on the first error. ``` #!/bin/sh set -e make -f Makefile1 make -f Makefile2 : ``` If you need more control over the script overall, maybe remove `set -e` and instead explicitly exit on `make` failure: ``` make -f Makefile1 ...
9895995
How do I delete a table from a mysqldump
10
2012-03-27 19:07:24
<p>How do I delete the output for one big table inside a mysqldump with lots of tables in it?</p> <p>I have a dump of a database that is 6 GB large, but 90% of it is only one logging-table "cache_entries", that I don’t need anymore inside my backup.</p> <p>How can I easily remove that bit inside the dump, that descri...
14,582
1,069,083
2013-05-30 15:56:11
16,840,625
14
2013-05-30 15:51:02
1,069,083
2013-05-30 15:56:11
https://stackoverflow.com/q/9895995
https://stackoverflow.com/a/16840625
<p>I found this bash script, that splits a dump of one database into separate filed for each table, using <code>csplit</code> (that splits a file into sections determined by context lines):</p> <pre><code>#!/bin/bash #### # Split MySQL dump SQL file into one file per table # based on http://blog.tty.nl/2011/12/28/spl...
<p>I found this bash script, that splits a dump of one database into separate filed for each table, using <code>csplit</code> (that splits a file into sections determined by context lines):</p> <pre><code>#!/bin/bash #### # Split MySQL dump SQL file into one file per table # based on http://blog.tty.nl/2011/12/28/spl...
21, 387
bash, mysql
<h1>How do I delete a table from a mysqldump</h1> <p>How do I delete the output for one big table inside a mysqldump with lots of tables in it?</p> <p>I have a dump of a database that is 6 GB large, but 90% of it is only one logging-table "cache_entries", that I don’t need anymore inside my backup.</p> <p>How can I e...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,755
bash
# How do I delete a table from a mysqldump How do I delete the output for one big table inside a mysqldump with lots of tables in it? I have a dump of a database that is 6 GB large, but 90% of it is only one logging-table "cache_entries", that I don’t need anymore inside my backup. How can I easily remove that bit i...
I found this bash script, that splits a dump of one database into separate filed for each table, using `csplit` (that splits a file into sections determined by context lines): ``` #!/bin/bash #### # Split MySQL dump SQL file into one file per table # based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump ##...
15930323
Echo but retain double quotes
10
2013-04-10 15:36:57
<p>I'm trying to create a script which will echo varibles / text to a file - a snippet of this script is:</p> <pre><code>echo " SUBJECT="Text here" EMAIL="email@domain.co.uk" EMAILMESSAGE="/tmp/emailmessage.txt" " &gt; /root/email.txt </code></pre> <p>This is working fine but all of the double quotes are being remove...
9,841
1,978,420
2013-04-10 15:53:38
15,930,393
14
2013-04-10 15:39:56
827,263
2013-04-10 15:39:56
https://stackoverflow.com/q/15930323
https://stackoverflow.com/a/15930393
<p>Double quotes don't nest. Use single quotes:</p> <pre><code>echo ' SUBJECT="Text here" EMAIL="email@domain.co.uk" EMAILMESSAGE="/tmp/emailmessage.txt" ' &gt; /root/email.txt </code></pre> <p>But this will add empty lines to the top and bottom of the file. If you don't want those:</p> <pre><code>echo 'SUBJECT="Tex...
<p>Double quotes don't nest. Use single quotes:</p> <pre><code>echo ' SUBJECT="Text here" EMAIL="email@domain.co.uk" EMAILMESSAGE="/tmp/emailmessage.txt" ' &gt; /root/email.txt </code></pre> <p>But this will add empty lines to the top and bottom of the file. If you don't want those:</p> <pre><code>echo 'SUBJECT="Tex...
387, 390, 549, 13824
bash, echo, shell, ubuntu
<h1>Echo but retain double quotes</h1> <p>I'm trying to create a script which will echo varibles / text to a file - a snippet of this script is:</p> <pre><code>echo " SUBJECT="Text here" EMAIL="email@domain.co.uk" EMAILMESSAGE="/tmp/emailmessage.txt" " &gt; /root/email.txt </code></pre> <p>This is working fine but al...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,756
bash
# Echo but retain double quotes I'm trying to create a script which will echo varibles / text to a file - a snippet of this script is: ``` echo " SUBJECT="Text here" EMAIL="email@domain.co.uk" EMAILMESSAGE="/tmp/emailmessage.txt" " > /root/email.txt ``` This is working fine but all of the double quotes are being rem...
Double quotes don't nest. Use single quotes: ``` echo ' SUBJECT="Text here" EMAIL="email@domain.co.uk" EMAILMESSAGE="/tmp/emailmessage.txt" ' > /root/email.txt ``` But this will add empty lines to the top and bottom of the file. If you don't want those: ``` echo 'SUBJECT="Text here" EMAIL="email@domain.co.uk" EMAILM...
14127263
Using VIM command on all open files
10
2013-01-02 18:33:27
<p>I have a list of files i've opened in VIM using this command:</p> <pre><code>vim `cat list.txt` </code></pre> <p>I'm looking to run this command on all open files:</p> <pre><code>:99,104 norm i# </code></pre> <p>(from lines 99 to 104, insert a comment "#") &lt;--simple, works</p> <p>When I run the above command...
1,875
1,783,634
2013-01-03 01:07:20
14,127,291
14
2013-01-02 18:36:14
89,391
2013-01-02 19:02:35
https://stackoverflow.com/q/14127263
https://stackoverflow.com/a/14127291
<p>I guess <a href="http://vimdoc.sourceforge.net/htmldoc/windows.html#%3abufdo"><code>bufdo</code></a> would work, if you have <a href="http://vimdoc.sourceforge.net/htmldoc/options.html#%27hidden%27"><code>set hidden</code></a> (to allow <code>bufdo</code> to change buffers without saving) before:</p> <pre><code>:se...
<p>I guess <a href="http://vimdoc.sourceforge.net/htmldoc/windows.html#%3abufdo"><code>bufdo</code></a> would work, if you have <a href="http://vimdoc.sourceforge.net/htmldoc/options.html#%27hidden%27"><code>set hidden</code></a> (to allow <code>bufdo</code> to change buffers without saving) before:</p> <pre><code>:se...
293, 370, 387
bash, vi, vim
<h1>Using VIM command on all open files</h1> <p>I have a list of files i've opened in VIM using this command:</p> <pre><code>vim `cat list.txt` </code></pre> <p>I'm looking to run this command on all open files:</p> <pre><code>:99,104 norm i# </code></pre> <p>(from lines 99 to 104, insert a comment "#") &lt;--simpl...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,757
bash
# Using VIM command on all open files I have a list of files i've opened in VIM using this command: ``` vim `cat list.txt` ``` I'm looking to run this command on all open files: ``` :99,104 norm i# ``` (from lines 99 to 104, insert a comment "#") <--simple, works When I run the above command to insert it works as...
I guess [`bufdo`](http://vimdoc.sourceforge.net/htmldoc/windows.html#%3abufdo) would work, if you have [`set hidden`](http://vimdoc.sourceforge.net/htmldoc/options.html#%27hidden%27) (to allow `bufdo` to change buffers without saving) before: ``` :set hidden :bufdo 99,104 norm i# ``` Then save all files with `:bufdo!...
13757896
Script to count number of files in each directory
10
2012-12-07 06:13:24
<p>I need to count the number of files on a large number of directories. Is there an easy way to do this with a shell script (using find, wc, sed, awk or similar)? Just to avoid having to write a proper script in python.</p> <p>The output would be something like this:</p> <pre><code>$ &lt;magic_command&gt; dir1 2 di...
34,815
1,580,351
2018-05-10 19:10:21
13,757,973
14
2012-12-07 06:19:40
1,634,695
2012-12-07 06:19:40
https://stackoverflow.com/q/13757896
https://stackoverflow.com/a/13757973
<p>Try the below one:</p> <pre><code>du -a | cut -d/ -f2 | sort | uniq -c | sort -nr </code></pre> <p>from <a href="http://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-the-total-number-of-files-in-a-folder-510009/#post3466477">http://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-the-total...
<p>Try the below one:</p> <pre><code>du -a | cut -d/ -f2 | sort | uniq -c | sort -nr </code></pre> <p>from <a href="http://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-the-total-number-of-files-in-a-folder-510009/#post3466477">http://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-the-total...
390
shell
<h1>Script to count number of files in each directory</h1> <p>I need to count the number of files on a large number of directories. Is there an easy way to do this with a shell script (using find, wc, sed, awk or similar)? Just to avoid having to write a proper script in python.</p> <p>The output would be something li...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,758
bash
# Script to count number of files in each directory I need to count the number of files on a large number of directories. Is there an easy way to do this with a shell script (using find, wc, sed, awk or similar)? Just to avoid having to write a proper script in python. The output would be something like this: ``` $ ...
Try the below one: ``` du -a | cut -d/ -f2 | sort | uniq -c | sort -nr ``` from <http://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-the-total-number-of-files-in-a-folder-510009/#post3466477>
13251076
Calling PowerShell From C#
10
2012-11-06 12:28:49
<p>I am using <code>System.Management.Automation</code> DLL which allows me to call PowerShell within my C# application like so:</p> <pre><code>PowerShell.Create().AddScript("Get-Process").Invoke(); </code></pre> <p>What I am trying to do is call PowerShell but supply the input list. For example, in:</p> <pre><code...
18,687
288,393
2018-11-20 21:03:19
13,555,477
14
2012-11-25 21:02:51
520,612
2018-11-20 21:03:19
https://stackoverflow.com/q/13251076
https://stackoverflow.com/a/13555477
<p>A little bit late but:</p> <pre><code>PowerShell ps = PowerShell.Create(); ps.Runspace.SessionStateProxy.SetVariable("a", new int[] { 1, 2, 3 }); ps.AddScript("$a"); ps.AddCommand("foreach-object"); ps.AddParameter("process", ScriptBlock.Create("$_ * 2")); Collection&lt;PSObject&gt; results = ps.Invoke(); foreach (...
<p>A little bit late but:</p> <pre><code>PowerShell ps = PowerShell.Create(); ps.Runspace.SessionStateProxy.SetVariable("a", new int[] { 1, 2, 3 }); ps.AddScript("$a"); ps.AddCommand("foreach-object"); ps.AddParameter("process", ScriptBlock.Create("$_ * 2")); Collection&lt;PSObject&gt; results = ps.Invoke(); foreach (...
9, 526, 1362
automation, c#, powershell
<h1>Calling PowerShell From C#</h1> <p>I am using <code>System.Management.Automation</code> DLL which allows me to call PowerShell within my C# application like so:</p> <pre><code>PowerShell.Create().AddScript("Get-Process").Invoke(); </code></pre> <p>What I am trying to do is call PowerShell but supply the input lis...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,759
bash
# Calling PowerShell From C# I am using `System.Management.Automation` DLL which allows me to call PowerShell within my C# application like so: ``` PowerShell.Create().AddScript("Get-Process").Invoke(); ``` What I am trying to do is call PowerShell but supply the input list. For example, in: ``` 1, 2, 3 | ForEach-O...
A little bit late but: ``` PowerShell ps = PowerShell.Create(); ps.Runspace.SessionStateProxy.SetVariable("a", new int[] { 1, 2, 3 }); ps.AddScript("$a"); ps.AddCommand("foreach-object"); ps.AddParameter("process", ScriptBlock.Create("$_ * 2")); Collection<PSObject> results = ps.Invoke(); foreach (PSObject result in r...
11629304
locate my bash configuration file
10
2012-07-24 10:51:41
<p>Is there a way to find the name of the bash configuration file that is currently on use. I searched for the .profile or .bashrc but did not find them. However still I can print some of the env variables i.e $HOME, $PATH</p>
43,591
308,849
2025-09-23 05:50:13
11,630,214
14
2012-07-24 11:47:46
466,826
2012-07-24 11:47:46
https://stackoverflow.com/q/11629304
https://stackoverflow.com/a/11630214
<p>If you are using one of these <code>sudo su -</code>, <code>bash --login</code>, <code>ssh user@host</code>,<br> these are considered as login shell,<br> then you might want to try</p> <ol> <li>/etc/profile</li> <li>~/.bash_profile</li> <li>~/.bash_login</li> <li>~/.profile</li> </ol>
<p>If you are using one of these <code>sudo su -</code>, <code>bash --login</code>, <code>ssh user@host</code>,<br> these are considered as login shell,<br> then you might want to try</p> <ol> <li>/etc/profile</li> <li>~/.bash_profile</li> <li>~/.bash_login</li> <li>~/.profile</li> </ol>
387
bash
<h1>locate my bash configuration file</h1> <p>Is there a way to find the name of the bash configuration file that is currently on use. I searched for the .profile or .bashrc but did not find them. However still I can print some of the env variables i.e $HOME, $PATH</p>
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,760
bash
# locate my bash configuration file Is there a way to find the name of the bash configuration file that is currently on use. I searched for the .profile or .bashrc but did not find them. However still I can print some of the env variables i.e $HOME, $PATH
If you are using one of these `sudo su -`, `bash --login`, `ssh user@host`, these are considered as login shell, then you might want to try 1. /etc/profile 2. ~/.bash_profile 3. ~/.bash_login 4. ~/.profile
11019067
PowerShell: Convert an object to a string
10
2012-06-13 16:13:45
<p>We have Exchange Info Stores that begin with UsersA-B, UsersC-D, etc., and then some that are outside that naming convention.</p> <pre><code>$allIS = Get-MailboxDatabase | Where { $_.name -notlike "*Users*" } | Select Identity </code></pre> <p>I'll lookup a current user's info store, and ...
62,934
792,974
2019-06-11 17:30:47
11,020,221
14
2012-06-13 17:29:06
674,943
2019-06-11 17:28:50
https://stackoverflow.com/q/11019067
https://stackoverflow.com/a/11020221
<p>It is hard to tell if that could be optimized without seeing the second part... </p> <p>But it's pretty easy to get a flat array of identities. Either use <code>-ExpandProperty</code> on select, or use <code>foreach { $_.Identity }</code> instead of select:</p> <pre><code>$allIS = Get-MailboxDatabase | ? { $_.name...
<p>It is hard to tell if that could be optimized without seeing the second part... </p> <p>But it's pretty easy to get a flat array of identities. Either use <code>-ExpandProperty</code> on select, or use <code>foreach { $_.Identity }</code> instead of select:</p> <pre><code>$allIS = Get-MailboxDatabase | ? { $_.name...
526
powershell
<h1>PowerShell: Convert an object to a string</h1> <p>We have Exchange Info Stores that begin with UsersA-B, UsersC-D, etc., and then some that are outside that naming convention.</p> <pre><code>$allIS = Get-MailboxDatabase | Where { $_.name -notlike "*Users*" } | Select Identity </code></pre...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,761
bash
# PowerShell: Convert an object to a string We have Exchange Info Stores that begin with UsersA-B, UsersC-D, etc., and then some that are outside that naming convention. ``` $allIS = Get-MailboxDatabase | Where { $_.name -notlike "*Users*" } | Select Identity ``` I'll lookup a current user'...
It is hard to tell if that could be optimized without seeing the second part... But it's pretty easy to get a flat array of identities. Either use `-ExpandProperty` on select, or use `foreach { $_.Identity }` instead of select: ``` $allIS = Get-MailboxDatabase | ? { $_.name -notlike "*Users*" } | select -expand Ident...
10953812
Adding colors in python interpreter prompt, does not wrap properly
10
2012-06-08 18:01:38
<p>I would like to have a more colorful Python prompt in the terminal, just for readability. I currently have:</p> <pre><code>sys.ps1 = '\033[96m&gt;&gt;&gt; \033[0m' sys.ps2 = '\033[96m... \033[0m' </code></pre> <p>in my <code>PYTHONSTARTUP</code> file, which does give it colors as desired. However, any text over ...
4,149
812,786
2017-11-07 00:04:40
10,953,944
14
2012-06-08 18:12:11
505,154
2012-06-08 18:12:11
https://stackoverflow.com/q/10953812
https://stackoverflow.com/a/10953944
<p>Try the following:</p> <pre><code>sys.ps1 = '\001\033[96m\002&gt;&gt;&gt; \001\033[0m\002' sys.ps2 = '\001\033[96m\002... \001\033[0m\002' </code></pre> <p><a href="https://stackoverflow.com/a/9468954/505154">This answer to a similar question explains why the <code>\001</code> and <code>\002</code> are necessary.<...
<p>Try the following:</p> <pre><code>sys.ps1 = '\001\033[96m\002&gt;&gt;&gt; \001\033[0m\002' sys.ps2 = '\001\033[96m\002... \001\033[0m\002' </code></pre> <p><a href="https://stackoverflow.com/a/9468954/505154">This answer to a similar question explains why the <code>\001</code> and <code>\002</code> are necessary.<...
16, 387
bash, python
<h1>Adding colors in python interpreter prompt, does not wrap properly</h1> <p>I would like to have a more colorful Python prompt in the terminal, just for readability. I currently have:</p> <pre><code>sys.ps1 = '\033[96m&gt;&gt;&gt; \033[0m' sys.ps2 = '\033[96m... \033[0m' </code></pre> <p>in my <code>PYTHONSTARTUP...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,762
bash
# Adding colors in python interpreter prompt, does not wrap properly I would like to have a more colorful Python prompt in the terminal, just for readability. I currently have: ``` sys.ps1 = '\033[96m>>> \033[0m' sys.ps2 = '\033[96m... \033[0m' ``` in my `PYTHONSTARTUP` file, which does give it colors as desired. Ho...
Try the following: ``` sys.ps1 = '\001\033[96m\002>>> \001\033[0m\002' sys.ps2 = '\001\033[96m\002... \001\033[0m\002' ``` [This answer to a similar question explains why the `\001` and `\002` are necessary.](https://stackoverflow.com/a/9468954/505154)
10766004
Why Linux always output "^C" upon pressing of Ctrl+C?
10
2012-05-26 11:58:17
<p>I have been studying signals in Linux. And I've done a test program to capture SIGINT.</p> <pre class="lang-c++ prettyprint-override"><code>#include &lt;unistd.h&gt; #include &lt;signal.h&gt; #include &lt;iostream&gt; void signal_handler(int signal_no); int main() { signal(SIGINT, signal_handler); for (int i = 0...
4,217
866,732
2024-06-14 01:55:30
10,766,343
14
2012-05-26 12:47:53
905,902
2013-09-26 22:39:24
https://stackoverflow.com/q/10766004
https://stackoverflow.com/a/10766343
<p>It is the terminal (driver) that intercepts the ^C and translates it to a signal sent to the attached process (which is the shell) <code>stty intr ^B</code> would instruct the terminal driver to intercept a ^B instead. It is also the terminal driver that echoes the ^C back to the terminal.</p> <p>The shell is just ...
<p>It is the terminal (driver) that intercepts the ^C and translates it to a signal sent to the attached process (which is the shell) <code>stty intr ^B</code> would instruct the terminal driver to intercept a ^B instead. It is also the terminal driver that echoes the ^C back to the terminal.</p> <p>The shell is just ...
58, 387, 2481, 25657
bash, linux, sigint, signals
<h1>Why Linux always output "^C" upon pressing of Ctrl+C?</h1> <p>I have been studying signals in Linux. And I've done a test program to capture SIGINT.</p> <pre class="lang-c++ prettyprint-override"><code>#include &lt;unistd.h&gt; #include &lt;signal.h&gt; #include &lt;iostream&gt; void signal_handler(int signal_no); ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,763
bash
# Why Linux always output "^C" upon pressing of Ctrl+C? I have been studying signals in Linux. And I've done a test program to capture SIGINT. ``` #include <unistd.h> #include <signal.h> #include <iostream> void signal_handler(int signal_no); int main() { signal(SIGINT, signal_handler); for (int i = 0; i < 10; ++...
It is the terminal (driver) that intercepts the ^C and translates it to a signal sent to the attached process (which is the shell) `stty intr ^B` would instruct the terminal driver to intercept a ^B instead. It is also the terminal driver that echoes the ^C back to the terminal. The shell is just a process that sits a...
10705901
Interactive Select from List in Powershell
10
2012-05-22 16:12:12
<p>Is there a plugin or tool that will let me display a list of objects to a user (<code>Format-Table</code> style) and allow them to use the cursor to select a choice from the list, including potentially scrolling a long list? I would like to be able to do something like this:</p> <p><code>Get-User -anr $search |</co...
13,053
9,084
2012-05-23 05:02:41
10,713,720
14
2012-05-23 05:02:41
540,014
2012-05-23 05:02:41
https://stackoverflow.com/q/10705901
https://stackoverflow.com/a/10713720
<p>in <strong>v3</strong>:</p> <pre><code>Get-User -anr $search | Out-GridView -PassThru | Set-User -EnableAccount true </code></pre>
<p>in <strong>v3</strong>:</p> <pre><code>Get-User -anr $search | Out-GridView -PassThru | Set-User -EnableAccount true </code></pre>
526, 5052
menu, powershell
<h1>Interactive Select from List in Powershell</h1> <p>Is there a plugin or tool that will let me display a list of objects to a user (<code>Format-Table</code> style) and allow them to use the cursor to select a choice from the list, including potentially scrolling a long list? I would like to be able to do something ...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,764
bash
# Interactive Select from List in Powershell Is there a plugin or tool that will let me display a list of objects to a user (`Format-Table` style) and allow them to use the cursor to select a choice from the list, including potentially scrolling a long list? I would like to be able to do something like this: `Get-Use...
in **v3**: ``` Get-User -anr $search | Out-GridView -PassThru | Set-User -EnableAccount true ```
10571393
How to tell curl to check file existence before download?
10
2012-05-13 11:36:33
<p>I use this command to download a series of images:</p> <pre><code>curl -O --max-time 10 --retry 3 --retry-delay 1 http://site.com/image[0-100].jpg </code></pre> <p>Some images are corrupted, so I delete them.</p> <pre><code>for i in *.jpg; do jpeginfo -c $i || rm $i; done </code></pre> <p>How to tell <code>curl<...
9,446
348,785
2012-05-15 11:49:12
10,572,464
14
2012-05-13 14:17:40
1,389,742
2012-05-15 11:49:12
https://stackoverflow.com/q/10571393
https://stackoverflow.com/a/10572464
<p>If the target resource is static, <code>curl</code> has an option <code>-z</code> to only download a newer target copy.</p> <p>Usage example:</p> <pre><code>curl -z image0.jpg http://site.com/image0.jpg </code></pre> <p>An example for your case:</p> <p><code>for i in $(seq 0 100); do curl -z image$i.jpg -O --max...
<p>If the target resource is static, <code>curl</code> has an option <code>-z</code> to only download a newer target copy.</p> <p>Usage example:</p> <pre><code>curl -z image0.jpg http://site.com/image0.jpg </code></pre> <p>An example for your case:</p> <p><code>for i in $(seq 0 100); do curl -z image$i.jpg -O --max...
387, 1554
bash, curl
<h1>How to tell curl to check file existence before download?</h1> <p>I use this command to download a series of images:</p> <pre><code>curl -O --max-time 10 --retry 3 --retry-delay 1 http://site.com/image[0-100].jpg </code></pre> <p>Some images are corrupted, so I delete them.</p> <pre><code>for i in *.jpg; do jpeg...
q.PostTypeId = 1; a.PostTypeId = 2; EXISTS tag '%bash%' OR '%shell%'; a.Body contains code block; q.Score > 5; a.Score > 10
9,765
bash
# How to tell curl to check file existence before download? I use this command to download a series of images: ``` curl -O --max-time 10 --retry 3 --retry-delay 1 http://site.com/image[0-100].jpg ``` Some images are corrupted, so I delete them. ``` for i in *.jpg; do jpeginfo -c $i || rm $i; done ``` How to tell `...
If the target resource is static, `curl` has an option `-z` to only download a newer target copy. Usage example: ``` curl -z image0.jpg http://site.com/image0.jpg ``` An example for your case: `for i in $(seq 0 100); do curl -z image$i.jpg -O --max-time 10 --retry 3 --retry-delay 1 http://site.com/image$i.jpg; done...