Python Forum
Python script dioesn`t run all commands
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python script dioesn`t run all commands
#1
Hello I have a Linux machine that has python 2.6 when you log in and with this command scl enable rh-python36 bash I can change it to python 3.6.
I created a script that will run from crontab and it is like this:
import os

os.system("scl enable rh-python36 bash")
os.system("python launch.py")
The ideea is that after I launch this script that I wrote above it just changes the python version but it doesnt launches launch.py
Do you have any ideeas how I can make it work ?

Thanks
Reply
#2
python 2.6 is very old. Nothing older than 3.0 will be supported after Jan 1, 2020
see: https://pythonclock.org/
Reply
#3
Yes but how can I solve my problem to run both commands and work ?
Reply
#4
(Sep-25-2019, 11:37 AM)exploit123 Wrote: Yes but how can I solve my problem to run both commands and work ?

You should use built-in help in your Python 2.6. Python website has currently only 2.7.16 version documentation from 2.XX generation. You know, usual drill: help(os.system). However, I believe that there is not much useful information.

Also along Larz60+ lines, this is excerpt of current os.system documentation (version 3.7):

Quote:The subprocess module provides more powerful facilities for spawning new processes and retrieving their results; using that module is preferable to using this function. See the Replacing Older Functions with the subprocess Module section in the subprocess documentation for some helpful recipes.

I have no idea whether subprocess is available in 2.6
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#5
subprocess is available in 2.6: https://docs.python.org/release/2.6.1/li...ocess.html.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#6
Give direct Path to python version you want to use.
Try to chaining environment with system/subprocces to 3.6,then try to run make not work.
Example if i want to run a file with 3.8,have 3.7 as default now,can also switch system wide easy as i always use pyenv.
import subprocess

subprocess.call(["/home/tom/.pyenv/versions/3.8-dev/bin/python", "hello.py"])
As mention do not use os.system(),subprocess was new in Python 2.4.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,177 Jun-29-2023, 11:57 AM
Last Post: gologica
  Sending string commands from Python to a bluetooth device Rovelin 13 9,430 Aug-31-2021, 06:40 PM
Last Post: deanhystad
  Python library for win32 console commands eldiener 3 3,447 Aug-24-2021, 10:28 PM
Last Post: bowlofred
  Possible to execute a python script before log off/shutdown with input commands? Kaltex 1 2,255 May-18-2021, 06:31 AM
Last Post: Skaperen
  cant use ping, sudo or other commands in remote shell script. throwaway34 7 3,574 May-17-2021, 11:29 AM
Last Post: throwaway34
  Raspi Commands via Python (VS Code) Script AS4188 5 2,789 Oct-21-2020, 03:49 PM
Last Post: AS4188
  How to kill a bash script running as root from a python script? jc_lafleur 4 5,870 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,287 May-28-2020, 05:27 PM
Last Post: micseydel
  how to get PID's of linux commands executed through python modules? Manikandan_PS 4 3,043 Mar-12-2020, 07:16 AM
Last Post: Manikandan_PS
  Questions re: my first python app (GUI, cross-platform, admin/root-level commands)? DonnyBahama 0 1,723 Feb-27-2020, 08:14 PM
Last Post: DonnyBahama

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020