Hot answers tagged python
One way would be to log the PID of the python process in, say, /var/run then the bash script could see if the file with that PID exists and if it does if that PID is still running. Another possibility would be to use pgrep to see if the process is running if there is a unique enough part of the name (python is likely too common to use, but the py script ...
All versions of CentOS come with python pre-installed. Version 5 has python 2.4, 6 has 2.6, and 7 has 2.7. If you need python 2.7 on an old version of CentOS, you can use the IUS repos. To use the repo, you need to install the release RPM for your version of CentOS. For CentOS 6: rpm -Uvh ...
The shell doesn't know it's a python program, so it's trying to execute the commands as shell commands: you either need to tell it to use the python interpreter explicitly on the command line python Test.py or add a shebang to the top of your script file #!/usr/bin/env python
Just for fun: python -c 'import sys,fileinput,re;sys.stdout.writelines(re.sub("stuff", "changed", l, 1) for l in fileinput.input() if re.search("patternmatch", l))' file Don't do it:) Use sed/perl/awk
That shell wrapper looks like an init script, but apparently it isn't (hence you need to use sudo there; scripts run by init would not require this). This seems to be a very clumsy way to do this; the shell wrapper does not serve any purpose that could not be better served by the python program itself. Get rid of that; if you want an init script ...
Nowadays, almost every login-related software relies on pam, so it may be a good idea to use pam_exec module to execute your command after the login request to pam (and thus, before the return to the application). You may also look directly at pam modules, like described in this thread.
If your bash script is called my_script.sh, then add this at the top: #!/bin/bash for pid in $(pidof -x my_script.sh); do if [ $pid != $$ ]; then exit 1 fi done python python_app.py It will list all the PIDs related to my_script.sh and verify if they are the same of the process we are currently running. If not, then exits the script.
This comment was right; the web server was started before I added www-data to the git group. The web server was restarted when I rebooted for other reasons and the problem went away.
Let's do this using a simple example, consider for a file, we will replace each digit of a line with the string HELLO, if the line does not have any digit then leave it as it is : #!/usr/bin/env python2 import re with open('file.txt') as f: for line in f: if re.search(r'\d', line): print re.sub(r'\d', 'HELLO', line).rstrip('\n') ...
You have installed Python packages that are more recent than what your distribution provides. For example, you have python version 2.7.10-1 installed but your distribution only has version 2.7.5-5ubuntu3. APT doesn't downgrade packages unless explicitly told to do so. So for example if you try to install a package that depends on the exact version of ...
Your current method means two things are happening: You are seeing the output of subproccess processes can have a few outputs, here are two that can occur: STDOUT - information from the program being run STDERR - information on warnings errors the program has encountered. This is probably the one that is annoying you. Using options on the subprocess ...
If you'd like to package your application for installation on Debian systems, your best starting point is the dh-python package. You may also find the Debian Python FAQ, The Hitchhiker’s Guide to Packaging and the Python distutils useful references.
I'm not sure I understand your question. The following prints the stats (?) for the files given as arguments: perl -MPOSIX=ceil -E 'say ceil((-s)/15000.0) for(@ARGV)' *.dat Doing the same with a single line of Python is possible, but it's better avoided. :)
Browsing as guest, open Crosh (ctrl+alt+t) and run shell Does that work? Can you log in as 'chronos' without a password? Alternatively open VT2 shell (ctrl+alt+F2) Can you log in as 'chronos' in VT2 without password? If so, you should be able to use 'sudo' without a password in that environment. Have you setup any Google accounts and ...
This could because the config file is different between root and user make it just be able to start under root. I viewed this file under normal user ~/.config/terminator/config and try to remove this line to make it similar to the one in root use_custom_command = True For those who get the error with key-binding for hide_window, try to map it to ...
Only top voted, non community-wiki answers of a minimum length are eligible