I downloaded the program ImageMagik (www.imagemagick.org/). It can be executed from command line and takes command-line arguments which is perfect for me. How do I execute the program from within a module in Erlang?
You can use either os:cmd call
http://www.erlang.org/doc/man/os.html#cmd-1
or use port
open port http://www.erlang.org/doc/tutorial/c_port.html
Use emagick, https://github.com/kivra/emagick
which already has the necessary bindings ready.
Related
I'm trying to pass command line arguments to my already packaged app on execution.
(Already packaged with electron-builder and installed the .dmg on my mac)
I navigated into the /Applications/myApp.app/Contents/MacOS folder where the application executable is located. Then i run.
exec myApp --myNewArgument theFancyValue
For some reason "myNewArgument" does not appear in my process.argv array.
Am i missing anything? I thought the arguements will automaticly be passed to my electron main process.
I am thankfull for any help.
Yes, the passed command line arguments appear in the process.argv array, but only from the main process.
From a renderer process, you'll need to access the main process arguments using remote.process:
require('electron').remote.process.argv
https://www.electronjs.org/docs/api/command-line states that
(commandLine.appendSwitch(...)) This will not affect process.argv. The intended usage of this function is to control Chromium's behavior.
As such, only the appp.commandLine.getSwitchValue as mentioned in other comments allows you to get these command line switches
In addition to the use of switches as command line parameters, the use of arguments is also supported. Arguments take the form of "someData" in the final command line, where switches take the form "--namedParameter=someData".
In code, commandLine.appendArgument(value) is used to add the argument. These arguments are given before all switches in the generated command line.
They are also intended to affect Chromium's behavior. Again:
(commandLine.appendArgument(value)) Note: This will not affect process.argv. The intended usage of this function is to control Chromium's behavior.
Since there is no key for the parameter, there does not appear to be a way to directly read it from code as there is with a switch.
https://www.electronjs.org/docs/api/command-line-switches gives a list of supported switches.
In case of packaged source of electron app, command line arguments can be accessed using following function. Let's say if we have passed the command line argument as --myNewArgument=theFancyValue. It can be retrieved like this in the main.js:
import { app } from "electron";
app.commandLine.getSwitchValue("myNewArgument");
This works for development mode as well.
I host a server and I was wondering: is there any way to run chat commands through ComputerCraft? I want to be able to run /tps through the ComputerCraft terminal and then have it print out the TPS. Help would be greatly appreciated.
Thanks.
In the new Computercraft 1.7 there is a new type of computer, the Command Computer. It allows the user to run commands the same way as shell.run("mkdir", "foo"). It can only be obtained by ops, and can only directly be controlled (we are talking without using rednet and such) by ops
commands.exec(string command) -- Runs and outputs command output in chat.
commands.execAsync(string command) -- Quietly runs command without output.
Here is the wiki page:
Commands (API)
But if we are talking 1.6.4 (Which almost all modpacks use) there is no "stock" version of doing that.
Hope it helps /Tyrerexus
I believe that you can use this thing called the Chat Box.
http://ftbwiki.org/Chat_Box
It's not part of the default Computercraft, however. It is part of the Misc Peripherals mod I believe.
I'm very new to IDL (trying to do a POC for someone using it) and I am trying to run an external command. The line of code I have added is this:
spawn, 'C:\Program Files\ITT\IDL\IDL80\products\envi48\save_add\visual.exe'
I thought this was all that was needed to launch an external command. When I run the app, i can use the debugger to step through the code, and when I get to this line and Step over, my executable does not run. I see no messages in the debugger indicating any type of error.
I put the file visual.exe in the directory and can run it by hand with no issues. It just seems to step right over the code without executing it or reporting any error.
You can use the form:
spawn, cmd, result, errResult
to get the any error messages that might be generated from the cmd. In your particular case, I think you need to quote the path to the executable because of the space in the path.
Your usage of the spawn command is correct. Perhaps visual.exe is exiting prematurely
for some reason (for example, maybe the working directory when run via spawn isn't what
your external program is expecting.)
You might try writing a little script that starts visual.exe, then does a pause,
and then spawn the wrapper script instead of visual.exe directly. That might
give you a chance to see any error messages before the DOS window disappears.
I want to write a script in Lua for establishing an ssh connection to execute a command on a remote server
Can anyone give me a hint
Thank you
You can use os.execute ('ssh user#127.0.0.1') to make the connection, but you may have to use os.execute ('ssh user#127.0.0.1 &'..yourCommand) to make it execute afterwards in the shell, but I'm not entirely certain that it would work. It maybe better to create the script in Bash and execute that from Lua. If you needed to run differing commands, then you could have the script receive arguments.
As said by U319344, os.execute would be enough if you simply want to execute some program at the remote side.
If you need to interact with this program, you will need io.popen - it returns a file handle which you can use to read from and write to the remote command.
(And usually you will want to setup public-key authentication to not have to deal with passwords here.)
The simplest solution is to use io.popen as others suggested. If you want more control, try lpty.
I have a few Windows Services written in C# that I have setup to support being run from the command line as a console app if a specific parameter is passed. Works great but I would love to be able to detect whether the app is being run by the service control mananger or from a command line.
Is there any way to tell at runtime if my app was started by the SCM?
Environment.UserInteractive will return false if the process is running under the SCM.
The SCM will call your OnStart method, so you could mark that event and make sure when you run from the command line, you don't call OnStart. Or, you could check the startup parameters to see how the application was started.
In C the function StartServiceCtrlDispatcher() will fail with ERROR_FAILED_SERVICE_CONTROLLER_CONNECT. This is the best way in C, wonder if C# exposes any of this?
ERROR_FAILED_SERVICE_CONTROLLER_CONNECT
This error is returned if the program is being run as a console application rather than as a service. If the program will be run as a console application for debugging purposes, structure it such that service-specific code is not called when this error is returned.