Cocoa = How to run script in background without launching terminal in C - linux

In my Cocoa Application, I am running a script by using c functions like setenv() and popen(). It executes the script perfectly. But the issue is, At runtime, popen() opens the Terminal app and after the script is executed, It closes the Terminal app automatically. I want to execute the script without opening the Terminal app.
I found a solution to use NSAppleScript. But This class is available only in Foundation, but not available in Core Foundation. I want the same feature to be written in C. How to achieve this.
Please advice.

Use NSTask to execute the script. This allows you to have it run in background while still being able to specify environment variables, monitor output, etc.

Related

Electron: starting terminal in main window

I'm using something like
child_process.exec('start cmd.exe /K bash -c "some commands..."')
to start a terminal. Everything works fine. Of course the terminal opens as a separate window. Is there a way to embed this terminal in the main app window?
There are probably multiple ways to achieve this. One would be using something like xterm. Microsoft Visual Studio Code uses it I believe.
From their description:
Xterm.js is a terminal front-end component written in JavaScript that
works in the browser.
It enables applications to provide fully featured terminals to their
users and create great development experiences.

Can I deactivate a monitor/display with node/electron?

I, I'm writing an app with electron (http://electron.atom.io/). I would like to deactivate the monitor/display of the pc and only activate it again, when something in the app happens (for energy-saving). Is there a way to do this?
The only think I found, is the powerSaveBlocker (http://electron.atom.io/docs/api/power-save-blocker/) which doesn't help me...
You'll need to use native system APIs to do this, on Windows you can use one of the solutions proposed in Turn on/off monitor.
One of the ways you can do that is by executing batch files from electron/node in Windows , shell scripts in Linux and whatever MAC OS uses to execute commands.
These scripts would contain the OS level commands to turn on/off the display which are easily available .
When to fire these scripts would depend on your application logic .

Mule Esb run in background from linux command

i can't figure out how to start a mule esb from command terminal in linux without keep calling the wrapper, which obliges me to mantain active the terminal.
I can actually use this simple command (from bin directory):
./mule
Anyways, if i need to pass a parameter, like this:
./mule -Denv=prod
it keeps starting in foreground mode.
How can I achieve a background start with parameters?
thanks!
Just tried it: ./mule start works in background with params (if needed). You can then stop it running ./mule stop. HTH.
Mule will be handled by the script which is placed at MULE_HOME/bin/mule. This script supports start|stop|restart|status|dump|console.
For production mode Mule should be configured as deamon as well - systemctl or service.

Start Node Js Server Automatically on Pc Start Up

I have a Node Server.
And I want that my Node Server starts automatically when my Pc Starts.
Right Now I am doing this Manually.
Like this:
1) First I open Command Prompt.
2) Than I Type
cd node
3) Thank I type
node server.js
I want these 3 Step to perform automatically when my Pc starts.
Any solution please ?
The simple way would be to write a .bat script that you launch on startup.
Another option, that I personally would have used, is node-windows (or other modules like it) to create a Windows Service, running it in the background. You can specify if you want your Service to start automatically in the background or not when Windows starts.
Write a simple .bat script and add the script as described here.
Assuming you mean Windows (cmd), this should work for you. Also it might be a good idea to specify an absolute path for the node executable, and/or file.

How to execute a setup from an application to update it?

I'am currently writing an application that has to search on a web site if an update exists for this application. If it is the case the application download a setup file (created with inosetup) and then execute it.
My application is written in C++. And I do not arrive to do this process. I'am trying to call the setup using system(). If the command is system("mysetup") I cannot obtain what I want because the setup cannot replace the exe (currently running). So, I have tried to use system("cmd /C mysetup"), system("cmd/C start /min mysetup"), system ("cmd /C start /min /separate mysetup") without success. In these cases, the fact to stop the application also stop the setup. So I suppose that the setup is considered as a child process.
I have seen in some posts that it might be possible to use execcl(). But this function is in unistd.h. And this library is a little bit to specific for my needs (I need to be able to run on virtualized windows).
So do you have a way to do what I want?
Thanks for your help
OK,
A colleague to me gave me the solution. As we are using QT a QProcess::startDetached does exactly what I want.

Resources