How do I run a Bash command via a PY file? [duplicate]Execute shell commands in PythonRun a Vim command from a bash scriptRun this PHP file via Cron JobBash: pyvenv: command not foundBash script works via terminal but not via main menused in bash scripting troubleshootingCannot run remote script via bash script but can through terminalHow to run a .desktop file in pygtk?run bash script doesn't work alias command in zshHow to run ssh command until succeeded?Cannot run python file, asks to relink libraries

What is the white spray-pattern residue inside these Falcon Heavy nozzles?

Are white and non-white police officers equally likely to kill black suspects?

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?

Are tax years 2016 & 2017 back taxes deductible for tax year 2018?

Can Medicine checks be used, with decent rolls, to completely mitigate the risk of death from ongoing damage?

How does one intimidate enemies without having the capacity for violence?

How can bays and straits be determined in a procedurally generated map?

Why do we use polarized capacitor?

The use of multiple foreign keys on same column in SQL Server

How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?

Simulate Bitwise Cyclic Tag

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

How is the relation "the smallest element is the same" reflexive?

Is it possible to do 50 km distance without any previous training?

cryptic clue: mammal sounds like relative consumer (8)

Is there a familial term for apples and pears?

Is there really no realistic way for a skeleton monster to move around without magic?

Why is "Reports" in sentence down without "The"

How to make payment on the internet without leaving a money trail?

Can you lasso down a wizard who is using the Levitate spell?

Motorized valve interfering with button?

Download, install and reboot computer at night if needed

Why don't electron-positron collisions release infinite energy?

Concept of linear mappings are confusing me



How do I run a Bash command via a PY file? [duplicate]


Execute shell commands in PythonRun a Vim command from a bash scriptRun this PHP file via Cron JobBash: pyvenv: command not foundBash script works via terminal but not via main menused in bash scripting troubleshootingCannot run remote script via bash script but can through terminalHow to run a .desktop file in pygtk?run bash script doesn't work alias command in zshHow to run ssh command until succeeded?Cannot run python file, asks to relink libraries






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1
















This question already has an answer here:



  • Execute shell commands in Python

    6 answers



The following Python script is extracted from /usr/lib/python2.7/dist-packages/Mailnag/plugins/libnotifyplugin.py

In the script, the command ('zenity --info --text="You got new mail"') is not run. How do I make it run? I want it to run when mail_count > 0

The lines under if mail_count > 1: are run properly.



if mail_count > 0:
import os
os.system('zenity --info --text="You got new mail"')

if mail_count > 1:
summary = _("0 new mails").format(str(mail_count))
if (mail_count - i) > 1:
body = _("from 0 and others.").format(senders)
else:
body = _("from 0.").format(senders)
else:
summary = _("New mail")
body = _("from 0.").format(senders)


I put the following "Testing.py" script into /usr/lib/python2.7/dist-packages/Mailnag/plugins/Testing.py and ran it, which did bring up the "You got new mail" message.



#!/usr/bin/env python2
import os
os.system('zenity --info --text="You got new mail"')









share|improve this question















marked as duplicate by Stephen Kitt, Rui F Ribeiro, muru, Prvt_Yadv, GAD3R 2 days ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • I just edited my question. Please read it again.

    – Matthew Wai
    2 days ago






  • 1





    OK, that changes your question substantially, which isn’t really how this site works, but whatever. Are you sure your formatting accurately represents the indentation of your Python script? When you say the Zenity command isn’t run, what happens instead? What’s the return value of os.system?

    – Stephen Kitt
    2 days ago

















-1
















This question already has an answer here:



  • Execute shell commands in Python

    6 answers



The following Python script is extracted from /usr/lib/python2.7/dist-packages/Mailnag/plugins/libnotifyplugin.py

In the script, the command ('zenity --info --text="You got new mail"') is not run. How do I make it run? I want it to run when mail_count > 0

The lines under if mail_count > 1: are run properly.



if mail_count > 0:
import os
os.system('zenity --info --text="You got new mail"')

if mail_count > 1:
summary = _("0 new mails").format(str(mail_count))
if (mail_count - i) > 1:
body = _("from 0 and others.").format(senders)
else:
body = _("from 0.").format(senders)
else:
summary = _("New mail")
body = _("from 0.").format(senders)


I put the following "Testing.py" script into /usr/lib/python2.7/dist-packages/Mailnag/plugins/Testing.py and ran it, which did bring up the "You got new mail" message.



#!/usr/bin/env python2
import os
os.system('zenity --info --text="You got new mail"')









share|improve this question















marked as duplicate by Stephen Kitt, Rui F Ribeiro, muru, Prvt_Yadv, GAD3R 2 days ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • I just edited my question. Please read it again.

    – Matthew Wai
    2 days ago






  • 1





    OK, that changes your question substantially, which isn’t really how this site works, but whatever. Are you sure your formatting accurately represents the indentation of your Python script? When you say the Zenity command isn’t run, what happens instead? What’s the return value of os.system?

    – Stephen Kitt
    2 days ago













-1












-1








-1


1







This question already has an answer here:



  • Execute shell commands in Python

    6 answers



The following Python script is extracted from /usr/lib/python2.7/dist-packages/Mailnag/plugins/libnotifyplugin.py

In the script, the command ('zenity --info --text="You got new mail"') is not run. How do I make it run? I want it to run when mail_count > 0

The lines under if mail_count > 1: are run properly.



if mail_count > 0:
import os
os.system('zenity --info --text="You got new mail"')

if mail_count > 1:
summary = _("0 new mails").format(str(mail_count))
if (mail_count - i) > 1:
body = _("from 0 and others.").format(senders)
else:
body = _("from 0.").format(senders)
else:
summary = _("New mail")
body = _("from 0.").format(senders)


I put the following "Testing.py" script into /usr/lib/python2.7/dist-packages/Mailnag/plugins/Testing.py and ran it, which did bring up the "You got new mail" message.



#!/usr/bin/env python2
import os
os.system('zenity --info --text="You got new mail"')









share|improve this question

















This question already has an answer here:



  • Execute shell commands in Python

    6 answers



The following Python script is extracted from /usr/lib/python2.7/dist-packages/Mailnag/plugins/libnotifyplugin.py

In the script, the command ('zenity --info --text="You got new mail"') is not run. How do I make it run? I want it to run when mail_count > 0

The lines under if mail_count > 1: are run properly.



if mail_count > 0:
import os
os.system('zenity --info --text="You got new mail"')

if mail_count > 1:
summary = _("0 new mails").format(str(mail_count))
if (mail_count - i) > 1:
body = _("from 0 and others.").format(senders)
else:
body = _("from 0.").format(senders)
else:
summary = _("New mail")
body = _("from 0.").format(senders)


I put the following "Testing.py" script into /usr/lib/python2.7/dist-packages/Mailnag/plugins/Testing.py and ran it, which did bring up the "You got new mail" message.



#!/usr/bin/env python2
import os
os.system('zenity --info --text="You got new mail"')




This question already has an answer here:



  • Execute shell commands in Python

    6 answers







scripting python3






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago







Matthew Wai

















asked 2 days ago









Matthew WaiMatthew Wai

1336




1336




marked as duplicate by Stephen Kitt, Rui F Ribeiro, muru, Prvt_Yadv, GAD3R 2 days ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Stephen Kitt, Rui F Ribeiro, muru, Prvt_Yadv, GAD3R 2 days ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • I just edited my question. Please read it again.

    – Matthew Wai
    2 days ago






  • 1





    OK, that changes your question substantially, which isn’t really how this site works, but whatever. Are you sure your formatting accurately represents the indentation of your Python script? When you say the Zenity command isn’t run, what happens instead? What’s the return value of os.system?

    – Stephen Kitt
    2 days ago

















  • I just edited my question. Please read it again.

    – Matthew Wai
    2 days ago






  • 1





    OK, that changes your question substantially, which isn’t really how this site works, but whatever. Are you sure your formatting accurately represents the indentation of your Python script? When you say the Zenity command isn’t run, what happens instead? What’s the return value of os.system?

    – Stephen Kitt
    2 days ago
















I just edited my question. Please read it again.

– Matthew Wai
2 days ago





I just edited my question. Please read it again.

– Matthew Wai
2 days ago




1




1





OK, that changes your question substantially, which isn’t really how this site works, but whatever. Are you sure your formatting accurately represents the indentation of your Python script? When you say the Zenity command isn’t run, what happens instead? What’s the return value of os.system?

– Stephen Kitt
2 days ago





OK, that changes your question substantially, which isn’t really how this site works, but whatever. Are you sure your formatting accurately represents the indentation of your Python script? When you say the Zenity command isn’t run, what happens instead? What’s the return value of os.system?

– Stephen Kitt
2 days ago










1 Answer
1






active

oldest

votes


















0














As you don't need to capture the output of the sys command, os.system is just fine.

As your posted code seems to be fine, try to guess if the zenity command you run is available at the path, where you run the python script.



Just to check that your output works, you could:



if mail_count > 0:
import os
result = os.system('echo "more than 0" > testfile')
if result == 0:
print("a testfile was created")


If that command generates the testfile, you know your issue is on zenity side.



Note

It is a good practice, import sentences are better placed at the beginning of the file, when possible.






share|improve this answer























  • @ Evhz, I added your lines into the script and tried again. No "testfile" was generated although my account does have new mail. FYI, the script is extracted from /usr/lib/python2.7/dist-packages/Mailnag/plugins/libnotifyplugin.py. Should I post the complete script here? It is a long script.

    – Matthew Wai
    2 days ago












  • it looks, the user running the python script, does not have write permissions on the folder you use as output. It could be, the user has no rights or visibility to the zenity command. Check which user runs your script and everything regarding files and folders visibility for it.

    – Evhz
    2 days ago












  • I am the only user on my Linux MInt. I have every right to run any commands. I just added something at the bottom of my question.

    – Matthew Wai
    2 days ago

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














As you don't need to capture the output of the sys command, os.system is just fine.

As your posted code seems to be fine, try to guess if the zenity command you run is available at the path, where you run the python script.



Just to check that your output works, you could:



if mail_count > 0:
import os
result = os.system('echo "more than 0" > testfile')
if result == 0:
print("a testfile was created")


If that command generates the testfile, you know your issue is on zenity side.



Note

It is a good practice, import sentences are better placed at the beginning of the file, when possible.






share|improve this answer























  • @ Evhz, I added your lines into the script and tried again. No "testfile" was generated although my account does have new mail. FYI, the script is extracted from /usr/lib/python2.7/dist-packages/Mailnag/plugins/libnotifyplugin.py. Should I post the complete script here? It is a long script.

    – Matthew Wai
    2 days ago












  • it looks, the user running the python script, does not have write permissions on the folder you use as output. It could be, the user has no rights or visibility to the zenity command. Check which user runs your script and everything regarding files and folders visibility for it.

    – Evhz
    2 days ago












  • I am the only user on my Linux MInt. I have every right to run any commands. I just added something at the bottom of my question.

    – Matthew Wai
    2 days ago















0














As you don't need to capture the output of the sys command, os.system is just fine.

As your posted code seems to be fine, try to guess if the zenity command you run is available at the path, where you run the python script.



Just to check that your output works, you could:



if mail_count > 0:
import os
result = os.system('echo "more than 0" > testfile')
if result == 0:
print("a testfile was created")


If that command generates the testfile, you know your issue is on zenity side.



Note

It is a good practice, import sentences are better placed at the beginning of the file, when possible.






share|improve this answer























  • @ Evhz, I added your lines into the script and tried again. No "testfile" was generated although my account does have new mail. FYI, the script is extracted from /usr/lib/python2.7/dist-packages/Mailnag/plugins/libnotifyplugin.py. Should I post the complete script here? It is a long script.

    – Matthew Wai
    2 days ago












  • it looks, the user running the python script, does not have write permissions on the folder you use as output. It could be, the user has no rights or visibility to the zenity command. Check which user runs your script and everything regarding files and folders visibility for it.

    – Evhz
    2 days ago












  • I am the only user on my Linux MInt. I have every right to run any commands. I just added something at the bottom of my question.

    – Matthew Wai
    2 days ago













0












0








0







As you don't need to capture the output of the sys command, os.system is just fine.

As your posted code seems to be fine, try to guess if the zenity command you run is available at the path, where you run the python script.



Just to check that your output works, you could:



if mail_count > 0:
import os
result = os.system('echo "more than 0" > testfile')
if result == 0:
print("a testfile was created")


If that command generates the testfile, you know your issue is on zenity side.



Note

It is a good practice, import sentences are better placed at the beginning of the file, when possible.






share|improve this answer













As you don't need to capture the output of the sys command, os.system is just fine.

As your posted code seems to be fine, try to guess if the zenity command you run is available at the path, where you run the python script.



Just to check that your output works, you could:



if mail_count > 0:
import os
result = os.system('echo "more than 0" > testfile')
if result == 0:
print("a testfile was created")


If that command generates the testfile, you know your issue is on zenity side.



Note

It is a good practice, import sentences are better placed at the beginning of the file, when possible.







share|improve this answer












share|improve this answer



share|improve this answer










answered 2 days ago









EvhzEvhz

1187




1187












  • @ Evhz, I added your lines into the script and tried again. No "testfile" was generated although my account does have new mail. FYI, the script is extracted from /usr/lib/python2.7/dist-packages/Mailnag/plugins/libnotifyplugin.py. Should I post the complete script here? It is a long script.

    – Matthew Wai
    2 days ago












  • it looks, the user running the python script, does not have write permissions on the folder you use as output. It could be, the user has no rights or visibility to the zenity command. Check which user runs your script and everything regarding files and folders visibility for it.

    – Evhz
    2 days ago












  • I am the only user on my Linux MInt. I have every right to run any commands. I just added something at the bottom of my question.

    – Matthew Wai
    2 days ago

















  • @ Evhz, I added your lines into the script and tried again. No "testfile" was generated although my account does have new mail. FYI, the script is extracted from /usr/lib/python2.7/dist-packages/Mailnag/plugins/libnotifyplugin.py. Should I post the complete script here? It is a long script.

    – Matthew Wai
    2 days ago












  • it looks, the user running the python script, does not have write permissions on the folder you use as output. It could be, the user has no rights or visibility to the zenity command. Check which user runs your script and everything regarding files and folders visibility for it.

    – Evhz
    2 days ago












  • I am the only user on my Linux MInt. I have every right to run any commands. I just added something at the bottom of my question.

    – Matthew Wai
    2 days ago
















@ Evhz, I added your lines into the script and tried again. No "testfile" was generated although my account does have new mail. FYI, the script is extracted from /usr/lib/python2.7/dist-packages/Mailnag/plugins/libnotifyplugin.py. Should I post the complete script here? It is a long script.

– Matthew Wai
2 days ago






@ Evhz, I added your lines into the script and tried again. No "testfile" was generated although my account does have new mail. FYI, the script is extracted from /usr/lib/python2.7/dist-packages/Mailnag/plugins/libnotifyplugin.py. Should I post the complete script here? It is a long script.

– Matthew Wai
2 days ago














it looks, the user running the python script, does not have write permissions on the folder you use as output. It could be, the user has no rights or visibility to the zenity command. Check which user runs your script and everything regarding files and folders visibility for it.

– Evhz
2 days ago






it looks, the user running the python script, does not have write permissions on the folder you use as output. It could be, the user has no rights or visibility to the zenity command. Check which user runs your script and everything regarding files and folders visibility for it.

– Evhz
2 days ago














I am the only user on my Linux MInt. I have every right to run any commands. I just added something at the bottom of my question.

– Matthew Wai
2 days ago





I am the only user on my Linux MInt. I have every right to run any commands. I just added something at the bottom of my question.

– Matthew Wai
2 days ago



Popular posts from this blog

getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.