I have a executable made by py2exe which verifies whether my VPN is connected or not at infinite loop running on Windows. I want to make sure it runs in background or hidden, I searched for several forums and I found 2 scripts worked partially.
Rename script to scrypt.py and run py2exe again, the .exe hide when I run it, but close or vanish. Doesn't continue running after the click.
I am made another exe to call the first
import os
import subprocess
os.chdir("C:\Users\dl\Documents\Log\Py")
proc = subprocess.Popen('ipLog.exe', creationflags=subprocess.SW_HIDE, shell=True)
proc.wait()
or
os.chdir("C:\Users\dl\Documents\Log\Py")
proc = subprocess.Popen('ipLog.exe', creationflags=subprocess.SW_HIDE, shell=True)
Works but the first command still visible, and when i close it, the first exe call by it quit too.
I tried install a module call self.hide but i cant.
I am newbie in python and try to change my hobbies vb, vba to python.
Thanks for any help.
I found a solution in this thread How to start daemon process from python on windows?. Thank you all people helped with this thread, help my script too.
Related
I'm able to execute an exe file via command prompt using below line:
process = subprocess.Popen("LogCollector.EXE ")
But the LogCollector.EXE GUI is still visible, Please suggest some method to run this completely in hidden way.
import os
os.system('start /MIN notepad.exe');
Use this command in the window, it will run the application and minimize the application.
Maybe it will help you
I recently started a project where I've ro use asterisk and AGI. So I started to learn how AGI works in python by using an example found on the internet. But when I paste the example and try to run the module in Python, shell gives me in red font "ARGS: ['usr/bla bla]" ( You can see the clear output in attached image). I don't know why this happens and program won't stop running (When I try to close the shell, it says program still runs).
Note: I'm using Python in my Raspberry Pi. Pyst package has been installed there.
In above image, left side is the script that I tried to run. Or I can say the example I got from the internet. Rightside it shows the shell. You can see the program still runs.
Please help me. How can I run this properly?
Sure it not give any output.
It wait for INPUT.
Please re-read documentation about AGI, give script needed info to STDIN if for some weird reason you run it not from asterisk.
I am a newbie with python and today I have tried to set the Spyder IDE to run PySide clases in order to make some applications. The thing is, once Spyder was installed (Spyder (Python 2.7) in Ubuntu) I tried to launch a hello world in order to check if all was correctly tied up. Before installing Spyder I had Python 2.7 with the PySide packages properly intalled. This is what my PySide Hello World program look like:
import sys
from PySide.QtCore import *
from PySide.QtGui import *
# Create a Qt application
app = QApplication(sys.argv)
# Create a Label and show it
label = QLabel("Hello World")
label.show()
# Enter Qt application main loop
app.exec_()
sys.exit()
When I tried to run the code pushing the Run File button (F5) the console only shows
runfile('/home/leo/.spyder2/temp.py', wdir='/home/leo/.spyder2')
And the same thing selectig a IPython console throws
runfile('/home/leo/.spyder2/temp.py', wdir='/home/leo/.spyder2')
It seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.
It seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.
It seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.
...etc...
But nothing happens, no application launched. However, if I select the whole text in the code editor, and then press F9 (which only executes the selected lines) everything works fine and the test application pops up!!! This happens with both Console and IPython Console.
I looked for some explanation about this awkward behaviour on the internet (like this post spider IDE python. Difference in running by pressing F5 and F9?) but in the end my question ends unanswered...
One more thing, executing the code in IPython console succesfully launches the test application, but once it is closed, a second attempt in the same console throws en error
RuntimeError: A QApplication instance already exists.
Any help would be very appreciated, thank you community.
p = subprocess.Popen([executable_file])
This is only code that I am using to run the python subprocess. However, it has unknown issue that cause my program cannot open the executable file as expected.
executable_file is one file link (PATH) that locate executable program.
Ex. C:\Users\SharkIng\Dev\WhatEverSystem\Builds\Windows\program-123456789-123456789.exe
The python subprocess.Popen should run the program. However, sometime it works and sometime it is not (I did not change any code between this two situation)
OS: Windows 10
Python: 2.7.*
Error: [Error 2] The system cannot find the file specified
BUT: It is working if you manually run subprocess.Popen([executable_file_path_string]) (with same file and path) it work.
WHY this happen?? Is that because some problem with Windows Python? or it is because my setting mess me up?
UPDATE: It is not some reason such as NOT FULL PATH. I can have it working with exact same code. If I ran same code in a python shell, by typing each line of code. It works. But if I put exact same code in a .py file and run it with python file.py, it showing the error
UPDATE 2: Another team member have same error with Windows 7 and Python 2.7.* This code used to work this morning. AGAIN I didn't change anything. That is way I am asking if it is unstable.
There is no problem with subprocess. If you want to run a specified executable, you need to give the full path to that file. The most likely reason you're seeing variable behavior is that sometimes you're in the directory with the .exe, and other times you're not.
I'm working on implementing a self-updater for a daemon on OS X. The update is published as a .pkg file, so what I'm trying to do is as follows:
When the daemon is notified that an update is available, it calls installer via the system() call to install the package. The package contains a newer version of the daemon, a preupgrade script that stops the daemon (launchctl unload /Library/LaunchDaemons/foo.plist), and a postflight script that starts it back up after the new version is installed. The problem I'm having is that the installer process is quitting prematurely. I suspect that it may be because the installer kills its parent process in order to update it, and then gets killed itself instead of continuing as its own orphan process. I've tried the following with no luck:
Postpending the installer command with '&' to run it in the
background
Wrapping the installer command with nohup
The install command completes consistently without error when I run it from the command line, and fails consistently when run from the installer. When called from the installer, I'm piping the output to a file, and sometimes it has nothing, and sometimes it shows the install getting to about 41% completion before output stops. Any ideas on how I can figure out what's happening to the process or make sure it stays alive without its parent?
When you call launchctl unload, it kills the entire process group (unlike a simple kill). You want to move your subprocess into a separate process group. The easiest way is with the C call setsid().
If you're in the middle of a shell script, you should look at the following approaches. I haven't tried these since I was dealing with a C program and could setsid():
Prior to calling the installer, use set -m. This is supposed to turn on monitor mode, which says "Background processes run in a separate process group and a line containing their exit status is printed upon their completion."
Try this sub-interative shell trick: New process group in shell script