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;
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"')
scripting python3
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.
add a comment |
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"')
scripting python3
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 ofos.system
?
– Stephen Kitt
2 days ago
add a comment |
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"')
scripting python3
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
scripting python3
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 ofos.system
?
– Stephen Kitt
2 days ago
add a comment |
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 ofos.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
add a comment |
1 Answer
1
active
oldest
votes
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.
@ 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
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
@ 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
add a comment |
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.
@ 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
add a comment |
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.
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.
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
add a comment |
@ 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
add a comment |
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