Comments (4)
The list: '
, "
, &
, (
, )
, ;
, <
, ```, |
from wonderful_bing.
Hey, I found something in the subprocess module documentation, which you can use $pydoc -p 6789
to get them.
Replacing os.system()
---------------------
sts = os.system("mycmd" + " myarg")
==>
p = Popen("mycmd" + " myarg", shell=True)
pid, sts = os.waitpid(p.pid, 0)
Note:
* Calling the program through the shell is usually not required.
* It's easier to look at the returncode attribute than the
exitstatus.
A more real-world example would look like this:
try:
retcode = call("mycmd" + " myarg", shell=True)
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -retcode
else:
print >>sys.stderr, "Child returned", retcode
except OSError, e:
print >>sys.stderr, "Execution failed:", e
from wonderful_bing.
It seems that args should be a sequence of program arguments, or a string with shell set to True.
Something about shell=True
, get more information from here: Frequently Used Arguments
Warning
Executing shell commands that incorporate unsanitized input from an untrusted source makes a program vulnerable to shell injection, a serious security flaw which can result in arbitrary command execution. For this reason, the use of shell=True is strongly discouraged in cases where the command string is constructed from external input:
from wonderful_bing.
It seems that use a sequence of program arguments as args will be a good idea, you don't have to worry about the special characters(except " if I use "blabla").
>>>subprocess.call(['echo', "Today's Picture Story"])
Today's Picture Story
0
>>> subprocess.call('echo "Today's Picture Story"', shell=True)
File "<stdin>", line 1
subprocess.call('echo "Today's Picture Story"', shell=True)
^
SyntaxError: invalid syntax
>>> subprocess.call('echo "Today\'s Picture Story"', shell=True)
Today's Picture Story
0
from wonderful_bing.
Related Issues (19)
- Distribute to PyPI
- Fix the problem in notify HOT 1
- The crontab didn't work as we want.
- The notify didn't show the icon HOT 2
- Get picture info from different site.
- Support python3? HOT 2
- Fail to get today's story name HOT 1
- Test HOT 2
- About the wired picture url
- Coverage HOT 1
- We need better tests. HOT 1
- More platforms support? More desktop environtment support? HOT 6
- Change the command?
- Get the story content via command line HOT 1
- Get different zone's picture HOT 6
- Can't get the right desktop environment if you use cron or add it to startup HOT 1
- Refactor code
- bing set -d ~/Obrázky/ gnome HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wonderful_bing.