My company uses CYCLANCE and CYCLANCEProtect is preventing me to run Pkg.build(). Is it possible to stop Julia from using Powershell on Windows 7 and use cmd instead?
Here is an example:
julia> Pkg.build("Gumbo")
INFO: Building Gumbo
CylancePROTECT Script Control has blocked access to this PowerShell script.
CylancePROTECT Script Control has blocked access to this PowerShell script.
====================================================[ ERROR: Gumbo ]=======
You could try to use cURL for downloading which is also available on windows (here are some installation instructions). Julia allows to override the download function by defining a function with the same name:
function Base.download(url::AbstractString, filename::AbstractString)
run(`curl -L -f -o $filename $url`)
filename
end
Once you paste this code in the julia REPL, julia should use this cURL download function (instead of PowerShell). If you want to make this permanent you can put this code in a file called .juliarc.jl (in the home directory, i.e. the output of homedir()).
Related
I am trying to install Metricbeat on a Windows 10 machine so we can start monitoring it. When I open Powershell and run the following commands:
PS > .\metricbeat.exe modules list
I get the error
I copied that command as is from the Metricbeat documentation. I have seen videos on youtube of people running similar commands successfully. Please, why am I getting that error and what can I do to get my metricbeat.exe powershell commands to work?
You're copying the command TOO literally.
you've entered in the prompt PS > .\metricbeat.exe modules list
where you should have entered .\metricbeat.exe modules list
the latter executes modules list action against an application named "metricbeat.exe" located in .\ which indicates the current directory.
the former executes a redirection > of the output of an application named PS or get-process with input of .\metricbeat.exe modules and an argument of list.
wherever you copied this command from intended "PS >" to represent the beginning of the prompt and you don't need to include it.
Just like the error says... :P
I'm attempting to execute a script from the shell (Mac OS) using Octave, and this is exactly what I type:
$ open -a octave "my_script.m"
The result, is that Octave (the full application in the GUI) opens and doesn't run the script.
Ideally, I'd like Octave to actually run in Terminal (without the GUI), and execute whatever commands and scripts I type there, including, as noted above, an entire script stored in a .m file.
I also tried the following:
$ octave-cli my_script.m
Which produces the following error:
-bash: octave-cli: command not found
I installed Octave through a DMG file linked to on the official GNU website.
The command you're looking for is called octave-cli, and there's no need to open, just octave-cli my_script.m.
I would like to execute a bash command to activate a virtual environment with Octave using Linux. What I actually want to do is run DeepSpeech using Octave/Matlab.
The command I want to use is
source $HOME/tmp/deepspeech-venv/bin/activate
The line of code I tried on my own is system("source $HOME/tmp/deepspeech-venv/bin/activate")
And the output I'm getting is sh: 1: source: not found
I saw this answer on a post and tried this command setenv('PATH', ['/source $HOME/tmp/deepspeech-venv/bin/activate', pathsep, getenv('PATH')]) but with no help it returned the same error.
It's not completely clear from your question, but I'm assuming you're trying to do is run python commands within octave/matlab, and you'd like to use a python virtual environment for that.
Unfortunately, when you run a system command from within octave, what most likely happens is that this creates a subshell to execute your command, which is discarded once the command has finished.
You have several options to rectify this, but I think the easiest one would be to activate the python virtual environment first, and run your octave instance from within that environment. This then inherits all environmental variables as they existed when octave was run. You can confirm this by doing getenv( 'VIRTUAL_ENV' ).
If that's not an option, then you could make sure that all system commands intended to run python scripts, are prefixed with a call to the virtual environment first (e.g. something like system( 'source ./my/venv/activate; python3 ./myscript.py') ).
Alternatively, you can try to recreate the virtual environment from its exported variables manually, using the setenv command.
I have a very simple command in powershell to start SSH tunnels:
ssh -N -L 28777:localhost:28778 myapp-db
What's the simplest way to make this a service, so I can run:
start-service db-tunnel
etc on Windows 10? I've read an old article on doing this and it involves using C#, which seems way too complex for such a simple task.
PowerShell is not necessary. Here's one way:
Install the Windows Server 2003 Resource Kit Tools package somewhere and get the files instsrv.exe and srvany.exe.
Use srvany.exe to create the service using the ssh.exe program and its parameters using the information in Microsoft help article 137890.
For example:
instsrv "SSH Server" "C:\Program Files (x86)\Resource Kit Tools\srvany.exe"
Of course, specify whatever service name you want and the path and filename of srvany.exe.
Next, use the registry editor to go to HKLM\SYSTEM\CurrentControlSet\Services\SSH Tunnel (or whatever you named the service) in the registry and create a Parameters subkey. In the Parameters subkey create an Application value (REG_SZ type):
C:\Program Files (x86)\ssh\ssh.exe
(or whatever - the path and filename to your ssh executable).
You can also create the values AppDirectory (REG_SZ) to specify the starting directory for the executable, and AppParameters (REG_SZ) to specify the parameters to the executable; e.g.:
-N -L 28777:localhost:28778 myapp-db
You can substitute the use of the NSSM tool mentioned by BenH in his comment if you prefer that tool and are allowed to use third-party software.
To make something into a service, you would need to compile your script into an executable. This can be done via PS2EXE.
What may work just as well for you is making a function in powershell, Start-DbTunnel, and making that import into your powershell session on start. You can do this by loading functions in the foloowing path:
$PSprofilePath\Microsoft.PowerShell_profile.ps1
or for the ISE
$PSprofilePath\Microsoft.PowerShellISE_profile.ps1
Inside those files, I have
$PSprofilePath = "C:\Users\cknutson\Documents\WindowsPowershell"
$items = Get-ChildItem "$PSprofilePath\functions"
#Set-Location "$PSprofilePath\functions"
$items | ForEach-Object {
. $_.FullName
}
Set-Location C:\
Any scripts containing functions, or otherwise will be run each time you open a powershell host.
Making my PHP Command line application support Linux and Windows. Currently it has this code below to work from command line on Linux/unix
How can I make it work on Windows? I lan on having a setting to determine if the sytem is Linux or Windows and using the correct commands based on that but I do not know how to make these function below work in Windows
exec() is a PHP function to run stuff through the command line
exec("rm -f $dest_file", $var);
exec("mv $quant_file {$this->tmp_path}/{$src_filename}-quant.png");
You could test which platform you're on using the PHP_OS constant and run commands accordingly.
I would, however, suggest that you use the PHP provided filesystem functions (if possible).
Here are some links:
http://www.php.net/manual/en/ref.filesystem.php
http://www.php.net/manual/en/ref.dir.php